@@ -361,6 +361,57 @@ describe("makeQueryTemplate", () => {
361361 assert . deepStrictEqual ( parts . join ( "?" ) , "SELECT * FROM table1\nORDER BY col2 DESC\nOFFSET 10 ROWS\nFETCH NEXT 90 ROWS ONLY" ) ;
362362 assert . deepStrictEqual ( params , [ ] ) ;
363363 } ) ;
364+
365+ it ( "makeQueryTemplate throw if no columns are explicitly specified for oracle dialect" , ( ) => {
366+ const source = { name : "db" , dialect : "oracle" } ;
367+ const operations = {
368+ ...baseOperations ,
369+ select : {
370+ columns : null
371+ } ,
372+ sort : [ ] ,
373+ slice : { from : 10 , to : 100 }
374+ } ;
375+
376+ assert . throws ( ( ) => {
377+ makeQueryTemplate ( operations , source ) ;
378+ } , Error ) ;
379+ } ) ;
380+
381+ it ( "makeQueryTemplate select, sort, slice, filter indexed with oracle syntax" , ( ) => {
382+ const source = { name : "db" , dialect : "oracle" } ;
383+ const operations = {
384+ ...baseOperations ,
385+ select : {
386+ columns : [ "col1" , "col2" , "col3" ]
387+ } ,
388+ sort : [ { column : "col2" , direction : "desc" } ] ,
389+ slice : { from : 10 , to : 100 } ,
390+ filter : [
391+ {
392+ type : "gte" ,
393+ operands : [
394+ { type : "column" , value : "col1" } ,
395+ { type : "resolved" , value : "val1" }
396+ ]
397+ } ,
398+ {
399+ type : "eq" ,
400+ operands : [
401+ { type : "column" , value : "col2" } ,
402+ { type : "resolved" , value : "val2" }
403+ ]
404+ }
405+ ]
406+ } ;
407+
408+ const [ parts , ...params ] = makeQueryTemplate ( operations , source ) ;
409+ assert . deepStrictEqual (
410+ parts . join ( "?" ) ,
411+ "SELECT col1, col2, col3 FROM table1\nWHERE col1 >= ?\nAND col2 = ?\nORDER BY col2 DESC\nOFFSET 10 ROWS\nFETCH NEXT 90 ROWS ONLY"
412+ ) ;
413+ assert . deepStrictEqual ( params , [ "val1" , "val2" ] ) ;
414+ } ) ;
364415} ) ;
365416
366417describe ( "__table" , ( ) => {
0 commit comments