1- import { parse_sql , SQLVisitor , format , span , init } from '../dist/index' ;
1+ import { parse , SQLVisitor , format , span , init } from '../dist/index' ;
22import { jest } from '@jest/globals' ;
33
44beforeAll ( async ( ) => {
55 await init ( ) ;
66} ) ;
77
88it ( 'should be able to parse some SQL' , ( ) => {
9- const result = parse_sql ( "generic" , "SELECT * FROM users;" ) ;
9+ const result = parse ( "SELECT * FROM users;" ) ;
1010
1111 expect ( result ) . toMatchSnapshot ( ) ;
1212} ) ;
1313
1414it ( 'should be able to parse insert SQL' , ( ) => {
15- const result = parse_sql ( "generic" , "INSERT INTO users (id, name) VALUES (1, 'Alice'), (2, 'Bob');" ) ;
15+ const result = parse ( "INSERT INTO users (id, name) VALUES (1, 'Alice'), (2, 'Bob');" ) ;
1616
1717 expect ( result ) . toMatchSnapshot ( ) ;
1818} ) ;
1919
2020it ( 'should be able to parse update SQL' , ( ) => {
21- const result = parse_sql ( "generic" , "UPDATE users SET name = 'Charlie' WHERE id = 1;" ) ;
21+ const result = parse ( "UPDATE users SET name = 'Charlie' WHERE id = 1;" ) ;
2222
2323 expect ( result ) . toMatchSnapshot ( ) ;
2424} ) ;
2525
2626it ( 'should be able to parse delete SQL' , ( ) => {
27- const result = parse_sql ( "generic" , "DELETE FROM users WHERE id = 2;" ) ;
27+ const result = parse ( "DELETE FROM users WHERE id = 2;" ) ;
2828
2929 expect ( result ) . toMatchSnapshot ( ) ;
3030} ) ;
3131
3232it ( 'should support parameterized queries' , ( ) => {
33- const result = parse_sql ( "generic" , "SELECT * FROM users WHERE id = ?;" ) ;
33+ const result = parse ( "SELECT * FROM users WHERE id = ?;" ) ;
3434
3535 expect ( result ) . toMatchSnapshot ( ) ;
3636} ) ;
3737
3838it ( 'should be able to parse joins' , ( ) => {
39- const result = parse_sql ( "generic" , "SELECT * FROM users INNER JOIN orders ON users.id = orders.user_id;" ) ;
39+ const result = parse ( "SELECT * FROM users INNER JOIN orders ON users.id = orders.user_id;" ) ;
4040 expect ( result ) . toMatchSnapshot ( ) ;
4141} ) ;
4242
4343it ( 'should throw errors when parsing invalid SQL' , ( ) => {
44- expect ( ( ) => parse_sql ( "generic" , "SELEC * FROM users;" ) ) . toThrow ( "sql parser error: Expected: an SQL statement, found: SELEC at Line: 1, Column: 1" ) ;
44+ expect ( ( ) => parse ( "SELEC * FROM users;" ) ) . toThrow ( "sql parser error: Expected: an SQL statement, found: SELEC at Line: 1, Column: 1" ) ;
4545} ) ;
4646
4747describe ( 'visitor' , ( ) => {
@@ -90,7 +90,7 @@ describe('visitor', () => {
9090 } ) ;
9191
9292 it ( 'should call visitor methods when visiting a statement' , ( ) => {
93- const result = parse_sql ( "generic" , "SELECT * FROM users;" ) ;
93+ const result = parse ( "SELECT * FROM users;" ) ;
9494 expect ( result . length ) . toBe ( 1 ) ;
9595 const statement = result [ 0 ] ;
9696
@@ -109,7 +109,7 @@ describe('visitor', () => {
109109 } ) ;
110110
111111 it ( 'should call the statement visitors' , ( ) => {
112- const result = parse_sql ( "generic" , "SELECT * FROM users;" ) ;
112+ const result = parse ( "SELECT * FROM users;" ) ;
113113 expect ( result . length ) . toBe ( 1 ) ;
114114 const statement = result [ 0 ] ;
115115
@@ -122,7 +122,7 @@ describe('visitor', () => {
122122 } ) ;
123123
124124 it ( 'should call the query visitors' , ( ) => {
125- const result = parse_sql ( "generic" , "SELECT * FROM users;" ) ;
125+ const result = parse ( "SELECT * FROM users;" ) ;
126126 expect ( result . length ) . toBe ( 1 ) ;
127127
128128 const statement = result [ 0 ] ;
@@ -136,7 +136,7 @@ describe('visitor', () => {
136136 } ) ;
137137
138138 it ( 'should call the table factor visitors' , ( ) => {
139- const result = parse_sql ( "generic" , "SELECT * FROM users INNER JOIN orders ON users.id = orders.user_id;" ) ;
139+ const result = parse ( "SELECT * FROM users INNER JOIN orders ON users.id = orders.user_id;" ) ;
140140 expect ( result . length ) . toBe ( 1 ) ;
141141
142142 const statement = result [ 0 ] ;
@@ -212,7 +212,7 @@ describe('visitor', () => {
212212 } ) ;
213213
214214 it ( 'should call the relation visitors' , ( ) => {
215- const result = parse_sql ( "generic" , "SELECT * FROM users INNER JOIN orders ON users.id = orders.user_id;" ) ;
215+ const result = parse ( "SELECT * FROM users INNER JOIN orders ON users.id = orders.user_id;" ) ;
216216 expect ( result . length ) . toBe ( 1 ) ;
217217
218218 const statement = result [ 0 ] ;
@@ -248,7 +248,7 @@ describe('visitor', () => {
248248 } ) ;
249249
250250 it ( 'should call the value visitors' , ( ) => {
251- const result = parse_sql ( "generic" , "INSERT INTO users (id, name) VALUES (1, 'Alice'), (2, 'Bob');" ) ;
251+ const result = parse ( "INSERT INTO users (id, name) VALUES (1, 'Alice'), (2, 'Bob');" ) ;
252252 expect ( result . length ) . toBe ( 1 ) ;
253253
254254 const statement = result [ 0 ] ;
@@ -264,7 +264,7 @@ describe('visitor', () => {
264264 } ) ;
265265
266266 it ( 'should call the expr visitors' , ( ) => {
267- const result = parse_sql ( "generic" , "SELECT * FROM users WHERE id = 1 AND name = 'Alice';" ) ;
267+ const result = parse ( "SELECT * FROM users WHERE id = 1 AND name = 'Alice';" ) ;
268268 expect ( result . length ) . toBe ( 1 ) ;
269269
270270 const statement = result [ 0 ] ;
@@ -277,7 +277,7 @@ describe('visitor', () => {
277277
278278describe ( 'format' , ( ) => {
279279 it ( 'should be able to format some SQL' , ( ) => {
280- const result = parse_sql ( "generic" , "SELECT * FROM users;" ) ;
280+ const result = parse ( "SELECT * FROM users;" ) ;
281281
282282 expect ( result . length ) . toBe ( 1 ) ;
283283 const statement = result [ 0 ] ;
@@ -286,7 +286,7 @@ describe('format', () => {
286286 } ) ;
287287
288288 it ( 'should be able to format edited SQL' , ( ) => {
289- const result = parse_sql ( "generic" , "SELECT * FROM users;" ) ;
289+ const result = parse ( "SELECT * FROM users;" ) ;
290290
291291 expect ( result . length ) . toBe ( 1 ) ;
292292 const statement = result [ 0 ] ;
0 commit comments