test: add nested bracket test
This commit is contained in:
parent
e446fc0435
commit
d4ac1ae940
@ -27,6 +27,29 @@ describe('utils', () => {
|
||||
expect(result.length).toEqual(2);
|
||||
});
|
||||
|
||||
// test nested bracket
|
||||
test('split nested bracket sql', () => {
|
||||
const sql = `WITH cte_sales_amounts (staff, sales, year)
|
||||
AS
|
||||
(
|
||||
SELECT
|
||||
first_name + ' ' + last_name,
|
||||
SUM(quantity * list_price * (1 - discount)),
|
||||
YEAR(order_date)
|
||||
FROM
|
||||
sales.orders o
|
||||
INNER JOIN sales.order_items i ON i.order_id = o.order_id
|
||||
INNER JOIN sales.staffs s ON s.staff_id = o.staff_id
|
||||
)
|
||||
SELECT staff, sales
|
||||
FROM cte_sales_amounts
|
||||
WHERE year = 2018;
|
||||
SELECT * FROM table;`;
|
||||
const result = splitSql(sql);
|
||||
console.log(JSON.stringify(result));
|
||||
expect(result.length).toEqual(2);
|
||||
});
|
||||
|
||||
test('lexer', () => {
|
||||
const sql = `-- a ;
|
||||
select * from a;
|
||||
|
Loading…
Reference in New Issue
Block a user