-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
24 lines (21 loc) · 719 Bytes
/
test.js
File metadata and controls
24 lines (21 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var pgparser = require('./index');
var sql = `
SELECT
id,
first_name
FROM
users
`;
var correct = '[{"SelectStmt":{"targetList":[{"ResTarget":{"val":{"ColumnRef":{"fields":[{"String":{"str":"id"}}],"location":11}},"location":11}},{"ResTarget":{"val":{"ColumnRef":{"fields":[{"String":{"str":"first_name"}}],"location":17}},"location":17}}],"fromClause":[{"RangeVar":{"relname":"users","inhOpt":2,"relpersistence":"p","location":36}}],"op":0}}]';
pgparser.parse(sql).then((tree) => {
if(JSON.stringify(tree) !== correct) {
console.error("pgparse test failed!");
process.exit(1);
}
else {
console.log("pgparse test passed");
}
}, (e) => {
console.error("pgparse test failed!");
process.exit(1);
});