Skip to content

Commit e49ddf1

Browse files
committed
Format DROP SUBSCRIPTION
1 parent 707b701 commit e49ddf1

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/syntax/subscription.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { AllSubscriptionNodes } from "sql-parser-cst";
2-
import { group, indent, line, join } from "../print_utils";
2+
import { group, line, join } from "../print_utils";
33
import { CstToDocMap } from "../CstToDocMap";
44

5-
export const subscriptionMap: Partial<CstToDocMap<AllSubscriptionNodes>> = {
5+
export const subscriptionMap: CstToDocMap<AllSubscriptionNodes> = {
66
create_subscription_stmt: (print, node) =>
77
group(
88
join(line, [
@@ -12,4 +12,9 @@ export const subscriptionMap: Partial<CstToDocMap<AllSubscriptionNodes>> = {
1212
...(node.with ? [print.spaced(["with"])] : []),
1313
]),
1414
),
15+
16+
drop_subscription_stmt: (print) =>
17+
group(
18+
print.spaced(["dropSubscriptionKw", "ifExistsKw", "name", "behaviorKw"]),
19+
),
1520
};

test/postgresql/subscription.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,12 @@ describe("subscriptions", () => {
3434
`);
3535
});
3636
});
37+
38+
describe("DROP SUBSCRIPTION", () => {
39+
it(`formats DROP SUBSCRIPTION`, async () => {
40+
await testPostgresql(dedent`
41+
DROP SUBSCRIPTION IF EXISTS my_sub CASCADE
42+
`);
43+
});
44+
});
3745
});

0 commit comments

Comments
 (0)