@@ -186,17 +186,29 @@ describe('SqlDriver (QueryAST Format)', () => {
186186 expect ( results . length ) . toBe ( 5 ) ;
187187 } ) ;
188188
189+ it ( 'should use "where" and ignore "filters" when both are present' , async ( ) => {
190+ const results = await driver . find ( 'products' , {
191+ where : [ [ 'category' , '=' , 'Electronics' ] ] ,
192+ filters : [ [ 'category' , '=' , 'Furniture' ] ] ,
193+ } as any ) ;
194+
195+ // Only "where" is applied — returns Electronics, not Furniture
196+ expect ( results . every ( ( r : any ) => r . category === 'Electronics' ) ) . toBe ( true ) ;
197+ expect ( results . length ) . toBe ( 3 ) ;
198+ } ) ;
199+
189200 it ( 'should ignore legacy "sort" key — only "orderBy" is recognized' , async ( ) => {
190201 const results = await driver . find ( 'products' , {
191202 fields : [ 'name' ] ,
192- limit : 2 ,
203+ limit : 5 ,
204+ orderBy : [ { field : 'price' , order : 'desc' as const } ] ,
193205 sort : [ { field : 'price' , order : 'asc' as const } ] ,
194206 } as any ) ;
195207
196- // "sort" is not recognized — no ORDER BY applied, so order is insertion order
197- expect ( results . length ) . toBe ( 2 ) ;
198- // Without ORDER BY, results come in insertion order (Laptop, Mouse)
208+ // "sort" is ignored; "orderBy" (desc) is applied — most expensive first
209+ expect ( results . length ) . toBe ( 5 ) ;
199210 expect ( results [ 0 ] . name ) . toBe ( 'Laptop' ) ;
211+ expect ( results [ 4 ] . name ) . toBe ( 'Mouse' ) ;
200212 } ) ;
201213
202214 it ( 'should ignore legacy "skip" key — only "offset" is recognized' , async ( ) => {
0 commit comments