@@ -184,7 +184,7 @@ describe('[#20263] having — the 2026 control and the non-temporal columns answ
184184 [ 'a 2026 day $lt on max(date)' , { last_placed : { $lt : '2026-02-01' } } , [ 'c1' , 'c3' ] ] ,
185185 [ 'a 2026 instant $gt on min(datetime)' , { first_opened : { $gt : '2026-02-01T00:00:00.000Z' } } , [ 'c2' , 'c3' , 'c4' ] ] ,
186186 [ 'a wall clock $lt on max(time)' , { last_slot : { $lt : '12:00' } } , [ 'c1' ] ] ,
187- [ 'a string on sum — not temporal, not judged' , { total : { $gt : 'not-a-date' } } , [ ] ] ,
187+ [ 'a number on sum — not temporal, not judged' , { total : { $gt : 500 } } , [ 'c2' ] ] ,
188188 ] ;
189189 for ( const [ name , having , kept ] of KEPT ) {
190190 it ( `${ name } : keeps ${ kept . join ( ', ' ) || 'no group' } , engine and REST, both paths` , async ( ) => {
@@ -197,4 +197,20 @@ describe('[#20263] having — the 2026 control and the non-temporal columns answ
197197 }
198198 } ) ;
199199 }
200+
201+ // [#20351] A string on sum is not this door's, and it no longer keeps no
202+ // group with a 200: the number-comparand door refuses it, before any read.
203+ it ( 'a string on sum — not temporal: refused by the number-comparand door, engine and REST, both paths, no read' , async ( ) => {
204+ const { engine, post, reads } = await boot ( ) ;
205+ const having = { total : { $gt : 'not-a-date' } } ;
206+ for ( const path of [ 'native' , 'rows' ] as const ) {
207+ const err = await refusalOf ( engine . aggregate ( OBJECT , grouped ( path , having ) ) ) ;
208+ expect ( { code : err ?. code , status : err ?. status } , `engine, ${ path } ` ) . toEqual ( { code : 'INVALID_FILTER' , status : 400 } ) ;
209+ const res = await post ( grouped ( path , having ) as Record < string , unknown > ) ;
210+ expect ( res . _status , JSON . stringify ( res . _json ) ) . toBe ( 400 ) ;
211+ expect ( res . _json . code , `REST, ${ path } ` ) . toBe ( 'INVALID_FILTER' ) ;
212+ expect ( res . _json . error , `REST, ${ path } ` ) . toContain ( 'at having.total.$gt' ) ;
213+ }
214+ expect ( reads . n ) . toBe ( 0 ) ;
215+ } ) ;
200216} ) ;
0 commit comments