|
14 | 14 | * engine on that branch, and only there: |
15 | 15 | * - a projection that already names `id` is handed over as written (no |
16 | 16 | * second `id`); |
17 | | - * - no projection, or an empty one, stays a whole-row read (no projection is |
18 | | - * invented); |
| 17 | + * - no projection stays a whole-row read (no projection is invented); |
| 18 | + * - an empty projection is handed over as written, and the engine refuses it |
| 19 | + * (#27008): the node fails with that refusal carried, never a whole-row read; |
19 | 20 | * - the `find` branch (`limit > 1`) declares no top-level `id` and is not |
20 | 21 | * touched. |
21 | 22 | * |
@@ -152,15 +153,27 @@ describe('get_record answers the row id as output.id whatever its fields project |
152 | 153 | expect(result.output.record).toEqual({ id: rowId, title: 'alpha' }); |
153 | 154 | }); |
154 | 155 |
|
155 | | - for (const [label, config] of [['no fields', {}], ['empty fields', { fields: [] }]] as const) { |
156 | | - it(`control, ${label}: the whole row is read and the output is the engine's own answer`, async () => { |
157 | | - const whole: any = await ql.findOne(OBJECT.name, { where: { title: 'alpha' }, context: SYS }); |
158 | | - expect(whole.status, 'control: a whole-row read carries the unnamed columns').toBe('open'); |
159 | | - const { result, fields } = await readOne(config); |
160 | | - expect(fields, 'no projection is invented').toEqual((config as { fields?: unknown }).fields); |
161 | | - expect(result.output).toEqual({ record: whole, id: rowId, object: OBJECT.name }); |
162 | | - }); |
163 | | - } |
| 156 | + it("control, no fields: the whole row is read and the output is the engine's own answer", async () => { |
| 157 | + const whole: any = await ql.findOne(OBJECT.name, { where: { title: 'alpha' }, context: SYS }); |
| 158 | + expect(whole.status, 'control: a whole-row read carries the unnamed columns').toBe('open'); |
| 159 | + const { result, fields } = await readOne({}); |
| 160 | + expect(fields, 'no projection is invented').toBeUndefined(); |
| 161 | + expect(result.output).toEqual({ record: whole, id: rowId, object: OBJECT.name }); |
| 162 | + }); |
| 163 | + |
| 164 | + it("empty fields: handed to the engine as written, and the node fails with the engine's refusal carried (#27008)", async () => { |
| 165 | + handed.length = 0; |
| 166 | + const result = await getRecord.execute( |
| 167 | + { id: 'read', type: 'get_record', config: { objectName: OBJECT.name, filter: { title: 'alpha' }, fields: [] } }, |
| 168 | + new Map(), |
| 169 | + { runAs: 'system', flowName: 'pin_get_record_id' }, |
| 170 | + ); |
| 171 | + expect(handed, 'the node hands the empty projection over unchanged, once').toEqual([{ method: 'findOne', fields: [] }]); |
| 172 | + expect(result.success, 'an empty projection is refused, never read as the whole row').toBe(false); |
| 173 | + expect(result.output).toBeUndefined(); |
| 174 | + expect(result.innerRefusal).toMatchObject({ code: 'VALIDATION_ERROR' }); |
| 175 | + expect(result.error).toMatch(/^get_record\(pin_get_record_id\) failed: ObjectQL\.findOne\('pin_get_record_id'\) names no field in 'fields'/); |
| 176 | + }); |
164 | 177 |
|
165 | 178 | it('a downstream update_record filtering on read.id updates the row the narrowed get_record read', async () => { |
166 | 179 | await ql.insert(OBJECT.name, { title: 'beta', status: 'open' }, { context: SYS }); |
|
0 commit comments