Skip to content

Commit 8b6632c

Browse files
committed
parse commit statements
1 parent 70095a1 commit 8b6632c

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "oracle-sql-parser",
3-
"version": "0.0.7",
3+
"version": "0.1.0",
44
"description": "spec compliant parser for oracle sql",
55
"main": "index.js",
66
"scripts": {

src/pegjs/oracle.pegjs

+25
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,26 @@ stmt
149149
/ alter_table_stmt
150150
/ create_domain_stmt
151151
/ drop_domain_stmt
152+
/ commit_stmt
153+
154+
commit_stmt
155+
= operation:KW_COMMIT _
156+
work:KW_WORK? _
157+
settings:(
158+
op:KW_FORCE _ string:string _ integer:(COMMA _ x:integer { return x; })? {
159+
return { operation: op, string, integer };
160+
} /
161+
comment:(KW_COMMENT _ c:string { return c; }) _
162+
write:(wait:(KW_WAIT / KW_NOWAIT)? _ mode:(KW_BATCH / KW_IMMEDIATE)? { return { wait, mode }; })? {
163+
return { comment, write };
164+
}
165+
)? _ SEMI_COLON {
166+
return {
167+
work,
168+
settings,
169+
operation,
170+
};
171+
}
152172

153173
drop_domain_stmt
154174
= operation:KW_DROP _
@@ -2878,6 +2898,11 @@ KW_DOMAIN = 'domain'i !ident_start { return '
28782898
KW_EXISTS = 'exists'i !ident_start { return 'exists'; }
28792899
KW_IF = 'if'i !ident_start { return 'if'; }
28802900
KW_ENUM = 'enum'i !ident_start { return 'enum'; }
2901+
KW_WORK = 'work'i !ident_start { return 'work'; }
2902+
KW_COMMENT = 'comment'i !ident_start { return 'comment'; }
2903+
KW_WAIT = 'wait'i !ident_start { return 'wait'; }
2904+
KW_NOWAIT = 'nowait'i !ident_start { return 'nowait'; }
2905+
KW_BATCH = 'batch'i !ident_start { return 'batch'; }
28812906
28822907
KW_VARYING = 'varying'i !ident_start { return 'varying'; }
28832908
KW_VARCHAR = 'varchar'i !ident_start { return 'varchar'; }

test/statements/commit.test.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const { Parser } = require("../../");
2+
3+
const parser = new Parser();
4+
5+
describe("commit statement", () => {
6+
it("commit;", () => {
7+
const sql = "commit;";
8+
const ast = parser.parse(sql);
9+
const expected = {
10+
operation: "commit",
11+
work: null,
12+
settings: null,
13+
};
14+
expect(ast[0]).toMatchObject(expected);
15+
});
16+
});

0 commit comments

Comments
 (0)