@@ -216,3 +216,48 @@ describe('[#27008] the in-process engine refuses an empty projection', () => {
216216 expect ( row ) . toEqual ( { title : 'Ship' , project_id : { name : 'Apollo' } } ) ;
217217 } ) ;
218218} ) ;
219+
220+ /**
221+ * [#27165] A projection that is empty AFTER the unknown-plain-column tolerance
222+ * dropped every entry is an empty projection, and is refused with the same
223+ * refusal. Before, `find(obj, { fields: ['nope'] })` dropped `nope` (the #7589
224+ * tolerance) and then fell back to every column: a narrower request answered
225+ * wider. The tolerance itself stays for a mix of known and unknown columns.
226+ */
227+ describe ( '[#27165] a projection whose every column is unknown is an empty projection' , ( ) => {
228+ let engine : ObjectQL ;
229+ let reads : Array < { object : string ; fields : unknown } > ;
230+
231+ beforeEach ( async ( ) => {
232+ engine = new ObjectQL ( ) ;
233+ const made = makeDriver ( ) ;
234+ reads = made . reads ;
235+ engine . registerDriver ( made . driver , true ) ;
236+ await engine . init ( ) ;
237+ engine . registry . registerObject ( projectObject , 'test-package' ) ;
238+ engine . registry . registerObject ( taskObject , 'test-package' ) ;
239+ } ) ;
240+
241+ it ( 'find with only unknown columns is refused 400 VALIDATION_ERROR, naming them, before any driver read' , async ( ) => {
242+ const answer = await wireAnswer ( engine . find ( 'task_27008' , { fields : [ 'nope' , 'nada' ] } ) ) ;
243+ expect ( answer ) . toMatchObject ( { status : 400 , code : 'VALIDATION_ERROR' } ) ;
244+ expect ( answer . message ) . toContain ( declaredRefusal ( ) ) ;
245+ expect ( answer . message ) . toMatch ( / ^ O b j e c t Q L \. f i n d \( ' t a s k _ 2 7 0 0 8 ' \) n a m e s n o f i e l d i n ' f i e l d s ' : g o t \[ " n o p e " , " n a d a " \] / ) ;
246+ expect ( reads ) . toEqual ( [ ] ) ;
247+ } ) ;
248+
249+ it ( 'findOne with only unknown columns is refused the same way, before any driver read' , async ( ) => {
250+ const answer = await wireAnswer ( engine . findOne ( 'task_27008' , { where : { id : 't1' } , fields : [ 'nope' ] } ) ) ;
251+ expect ( answer ) . toMatchObject ( { status : 400 , code : 'VALIDATION_ERROR' } ) ;
252+ expect ( answer . message ) . toContain ( declaredRefusal ( ) ) ;
253+ expect ( answer . message ) . toMatch ( / ^ O b j e c t Q L \. f i n d O n e \( ' t a s k _ 2 7 0 0 8 ' \) n a m e s n o f i e l d i n ' f i e l d s ' : g o t \[ " n o p e " \] / ) ;
254+ expect ( reads ) . toEqual ( [ ] ) ;
255+ } ) ;
256+
257+ it ( 'CONTROL: a mix of known and unknown columns keeps the tolerance and projects the known ones' , async ( ) => {
258+ const [ row ] = await engine . find ( 'task_27008' , { fields : [ 'nope' , 'title' ] } ) ;
259+ expect ( row ) . toEqual ( { title : 'Ship' } ) ;
260+ const one = await engine . findOne ( 'task_27008' , { where : { id : 't1' } , fields : [ 'nope' , 'title' ] } ) ;
261+ expect ( one ) . toEqual ( { title : 'Ship' } ) ;
262+ } ) ;
263+ } ) ;
0 commit comments