Skip to content

Commit 3e89684

Browse files
committed
Support ABORT as alias for ROLLBACK
Fixes #99
1 parent 94b4c59 commit 3e89684

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/cst/Transaction.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export interface CommitTransactionStmt extends BaseNode {
6969

7070
export interface RollbackTransactionStmt extends BaseNode {
7171
type: "rollback_transaction_stmt";
72-
rollbackKw: Keyword<"ROLLBACK">;
72+
rollbackKw: Keyword<"ROLLBACK" | "ABORT">;
7373
transactionKw?: Keyword<"TRANSACTION" | "WORK">;
7474
savepoint?: RollbackToSavepoint;
7575
chain?: TransactionChainClause | TransactionNoChainClause;

src/parser.pegjs

+5-1
Original file line numberDiff line numberDiff line change
@@ -4771,7 +4771,7 @@ commit_kw
47714771
/ kw:END (&sqlite / &postgres) { return kw; }
47724772

47734773
rollback_transaction_stmt
4774-
= kw:ROLLBACK tKw:(__ transaction_kw)?
4774+
= kw:rollback_kw tKw:(__ transaction_kw)?
47754775
sp:(__ rollback_to_savepoint)?
47764776
chain:(__ transaction_chain_clause)? {
47774777
return loc({
@@ -4783,6 +4783,10 @@ rollback_transaction_stmt
47834783
});
47844784
}
47854785

4786+
rollback_kw
4787+
= ROLLBACK
4788+
/ &postgres x:ABORT { return x; }
4789+
47864790
rollback_to_savepoint
47874791
= toKw:(TO __) spKw:(SAVEPOINT __)? id:ident {
47884792
return loc({

test/transactions.test.ts

+12
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,18 @@ describe("transactions", () => {
124124
});
125125
});
126126

127+
dialect("postgresql", () => {
128+
describe("ABORT as alias for ROLLBACK", () => {
129+
it("supports ABORT", () => {
130+
testWc("ABORT");
131+
testWc("ABORT WORK");
132+
testWc("ABORT TRANSACTION");
133+
testWc("ABORT AND CHAIN");
134+
testWc("ABORT AND NO CHAIN");
135+
});
136+
});
137+
});
138+
127139
dialect(["mysql", "mariadb", "sqlite", "postgresql"], () => {
128140
describe("creating savepoints", () => {
129141
it("supports SAVEPOINT", () => {

0 commit comments

Comments
 (0)