@@ -8,8 +8,8 @@ describe('AST', () => {
88 let sql ;
99
1010 function getParsedSql ( sql ) {
11- const ast = parser . sqlToAst ( sql ) ;
12- return util . astToSQL ( ast ) ;
11+ const ast = parser . astify ( sql ) ;
12+ return parser . sqlify ( ast ) ;
1313 }
1414
1515 describe ( 'select statement' , ( ) => {
@@ -393,7 +393,7 @@ describe('AST', () => {
393393 limit : null
394394 } ;
395395
396- expect ( util . astToSQL ( ast ) ) . to . equal ( `SELECT \`a\` FROM \`t\` WHERE \`id\` ${ sqlOperator } (1, 2)` ) ;
396+ expect ( parser . sqlify ( ast ) ) . to . equal ( `SELECT \`a\` FROM \`t\` WHERE \`id\` ${ sqlOperator } (1, 2)` ) ;
397397 } ) ;
398398 } ) ;
399399
@@ -586,7 +586,7 @@ describe('AST', () => {
586586 let ast ;
587587
588588 it ( 'should replace single parameter' , ( ) => {
589- ast = parser . sqlToAst ( 'SELECT col FROM t WHERE id = :id' ) ;
589+ ast = parser . astify ( 'SELECT col FROM t WHERE id = :id' ) ;
590590 ast = util . replaceParams ( ast , { id : 1 } ) ;
591591
592592 expect ( ast . where ) . to . eql ( {
@@ -598,7 +598,7 @@ describe('AST', () => {
598598 } ) ;
599599
600600 it ( 'should replace multiple parameters' , ( ) => {
601- ast = parser . sqlToAst ( 'SELECT col FROM t WHERE id = :id AND "type" = :type' ) ;
601+ ast = parser . astify ( 'SELECT col FROM t WHERE id = :id AND "type" = :type' ) ;
602602 ast = util . replaceParams ( ast , { id : 1 , type : 'foobar' } ) ;
603603
604604 expect ( ast . where ) . to . eql ( {
@@ -620,7 +620,7 @@ describe('AST', () => {
620620 } ) ;
621621
622622 it ( 'should set parameter with string' , ( ) => {
623- ast = parser . sqlToAst ( 'SELECT col1 FROM t WHERE col2 = :name' ) ;
623+ ast = parser . astify ( 'SELECT col1 FROM t WHERE col2 = :name' ) ;
624624 ast = util . replaceParams ( ast , { name : 'John Doe' } ) ;
625625
626626 expect ( ast . where ) . to . eql ( {
@@ -632,7 +632,7 @@ describe('AST', () => {
632632 } ) ;
633633
634634 it ( 'should set parameter with boolean value' , ( ) => {
635- ast = parser . sqlToAst ( 'SELECT col1 FROM t WHERE isMain = :main' ) ;
635+ ast = parser . astify ( 'SELECT col1 FROM t WHERE isMain = :main' ) ;
636636 ast = util . replaceParams ( ast , { main : true } ) ;
637637
638638 expect ( ast . where ) . to . eql ( {
@@ -644,7 +644,7 @@ describe('AST', () => {
644644 } ) ;
645645
646646 it ( 'should set parameter with null value' , ( ) => {
647- ast = parser . sqlToAst ( 'SELECT col1 FROM t WHERE col2 = :param' ) ;
647+ ast = parser . astify ( 'SELECT col1 FROM t WHERE col2 = :param' ) ;
648648 ast = util . replaceParams ( ast , { param : null } ) ;
649649
650650 expect ( ast . where ) . to . eql ( {
@@ -656,7 +656,7 @@ describe('AST', () => {
656656 } ) ;
657657
658658 it ( 'should set parameter with array as value' , ( ) => {
659- ast = parser . sqlToAst ( 'SELECT col1 FROM t WHERE id = :ids' ) ;
659+ ast = parser . astify ( 'SELECT col1 FROM t WHERE id = :ids' ) ;
660660 ast = util . replaceParams ( ast , { ids : [ 1 , 3 , 5 , 7 ] } ) ;
661661
662662 expect ( ast . where ) . to . eql ( {
@@ -676,15 +676,15 @@ describe('AST', () => {
676676 } ) ;
677677
678678 it ( 'should throw an exception if no value for parameter is available' , ( ) => {
679- ast = parser . sqlToAst ( 'SELECT col FROM t WHERE id = :id' ) ;
679+ ast = parser . astify ( 'SELECT col FROM t WHERE id = :id' ) ;
680680
681681 expect ( ( ) => {
682682 util . replaceParams ( ast , { foo : 'bar' } ) ;
683683 } ) . to . throw ( 'no value for parameter :id found' ) ;
684684 } ) ;
685685
686686 it ( 'should return new AST object' , ( ) => {
687- ast = parser . sqlToAst ( 'SELECT col FROM t WHERE id = :id' ) ;
687+ ast = parser . astify ( 'SELECT col FROM t WHERE id = :id' ) ;
688688 const resolvedParamAST = util . replaceParams ( ast , { id : 1 } ) ;
689689
690690 expect ( ast ) . to . not . eql ( resolvedParamAST ) ;
@@ -747,7 +747,7 @@ describe('AST', () => {
747747 limit : null
748748 } ;
749749
750- expect ( util . astToSQL ( ast ) ) . to . equal ( `DELETE \`a\` FROM \`t\` WHERE \`id\` ${ sqlOperator } (1, 2)` ) ;
750+ expect ( parser . sqlify ( ast ) ) . to . equal ( `DELETE \`a\` FROM \`t\` WHERE \`id\` ${ sqlOperator } (1, 2)` ) ;
751751 } ) ;
752752 } ) ;
753753
@@ -883,7 +883,7 @@ describe('AST', () => {
883883 }
884884 }
885885
886- expect ( util . astToSQL ( ast ) ) . to . equal ( `UPDATE \`a\` SET \`col1\` = 5 WHERE \`id\` ${ sqlOperator } (1, 2)` ) ;
886+ expect ( parser . sqlify ( ast ) ) . to . equal ( `UPDATE \`a\` SET \`col1\` = 5 WHERE \`id\` ${ sqlOperator } (1, 2)` ) ;
887887 } ) ;
888888 } ) ;
889889
@@ -967,7 +967,7 @@ describe('AST', () => {
967967 } ) ;
968968
969969 it ( `should throw exception for drop statements` , ( ) => {
970- expect ( util . astToSQL . bind ( null , { type : 'Drop' } ) ) . to . throw ( Error , `Drop statements not supported at the moment` ) ;
970+ expect ( parser . sqlify . bind ( null , { type : 'Drop' } ) ) . to . throw ( Error , `Drop statements not supported at the moment` ) ;
971971 } ) ;
972972
973973 it ( 'Drop statement not surported!' , ( ) => {
0 commit comments