Skip to content

Commit 4b6050b

Browse files
committed
Support RESET ROLE
1 parent 243b05b commit 4b6050b

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

src/cst/Role.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ export type AllRoleStatements =
99
| CreateRoleStmt
1010
| AlterRoleStmt
1111
| DropRoleStmt
12-
| SetRoleStmt;
12+
| SetRoleStmt
13+
| ResetRoleStmt;
1314

1415
export type RoleSpecification = Identifier | FuncCall;
1516

@@ -126,3 +127,9 @@ export interface SetRoleStmt extends BaseNode {
126127
roleKw: Keyword<"ROLE">;
127128
name: Identifier | StringLiteral | Keyword<"NONE">;
128129
}
130+
131+
// RESET ROLE
132+
export interface ResetRoleStmt extends BaseNode {
133+
type: "reset_role_stmt";
134+
resetRoleKw: [Keyword<"RESET">, Keyword<"ROLE">];
135+
}

src/parser.pegjs

+6
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ ddl_statement_postgres
162162
/ alter_role_stmt
163163
/ drop_role_stmt
164164
/ set_role_stmt
165+
/ reset_role_stmt
165166

166167
dml_statement
167168
= compound_select_stmt
@@ -4568,6 +4569,11 @@ set_role_stmt
45684569
});
45694570
}
45704571

4572+
reset_role_stmt
4573+
= kw:(RESET __ ROLE) {
4574+
return loc({ type: "reset_role_stmt", resetRoleKw: read(kw) });
4575+
}
4576+
45714577
/**
45724578
* ------------------------------------------------------------------------------------ *
45734579
* *

src/showNode/role.ts

+3
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,7 @@ export const roleMap: FullTransformMap<string, AllRoleNodes> = {
2929
// SET ROLE
3030
set_role_stmt: (node) =>
3131
show([node.setKw, node.scopeKw, node.roleKw, node.name]),
32+
33+
// RESET ROLE
34+
reset_role_stmt: (node) => show([node.resetRoleKw]),
3235
};

test/ddl/role.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,12 @@ describe("role", () => {
196196
testWc("SET LOCAL ROLE NONE");
197197
});
198198
});
199+
200+
describe("RESET ROLE", () => {
201+
it("supports RESET ROLE", () => {
202+
testWc("RESET ROLE");
203+
});
204+
});
199205
});
200206

201207
notDialect("postgresql", () => {

0 commit comments

Comments
 (0)