Skip to content

Commit d92185d

Browse files
committed
Fix formatting of plain CREATE SEQUENCE
Fixes #48
1 parent 24671c7 commit d92185d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/syntax/sequence.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import { CstToDocMap } from "../CstToDocMap";
33
import { group, indent, join, line } from "../print_utils";
44

55
export const sequenceMap: CstToDocMap<AllSequenceNodes> = {
6-
create_sequence_stmt: (print) =>
6+
create_sequence_stmt: (print, node) =>
77
group([
88
print.spaced(["createKw", "kind", "sequenceKw", "ifNotExistsKw", "name"]),
9-
indent([print.dynamicLine(), join(line, print("options"))]),
9+
node.options.length > 0
10+
? indent([print.dynamicLine(), join(line, print("options"))])
11+
: [],
1012
]),
1113
alter_sequence_stmt: (print) =>
1214
group([

test/ddl/sequence.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import { testPostgresql } from "../test_utils";
33

44
describe("sequence", () => {
55
describe("create sequence", () => {
6+
it(`formats minimal CREATE SEQUENCE`, async () => {
7+
await testPostgresql(dedent`
8+
CREATE SEQUENCE my_seq
9+
`);
10+
});
11+
612
it(`formats CREATE SEQUENCE on a single line`, async () => {
713
await testPostgresql(dedent`
814
CREATE SEQUENCE my_seq START WITH 10 NO CYCLE MAXVALUE 1000

0 commit comments

Comments
 (0)