Skip to content

Commit

Permalink
Remove spurious trailing space
Browse files Browse the repository at this point in the history
This fixes issue #165.
  • Loading branch information
lelit committed Nov 26, 2024
1 parent ab138ed commit cfdddfe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pglast/printers/ddl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1330,8 +1330,9 @@ def CONSTR_IDENTITY(self, node, output):
output.write('ALWAYS ')
elif node.generated_when == enums.ATTRIBUTE_IDENTITY_BY_DEFAULT:
output.write('BY DEFAULT ')
output.write('AS IDENTITY ')
output.write('AS IDENTITY')
if node.options:
output.space()
with output.expression(True):
output.print_list(node.options, '')

Expand Down Expand Up @@ -1403,7 +1404,7 @@ def constraint(node, output):
output.write(' USING INDEX TABLESPACE ')
output.print_name(node.indexspace)
if node.skip_validation:
output.write(' NOT VALID ')
output.write(' NOT VALID')


@node_printer(ast.CreateAmStmt)
Expand Down
14 changes: 14 additions & 0 deletions tests/test_printers_prettification/ddl/alter_table.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
ALTER TABLE tab1 ADD CONSTRAINT foo FOREIGN KEY (id1) REFERENCES tab2 (id2) DEFERRABLE INITIALLY DEFERRED
=
ALTER TABLE tab1 ADD CONSTRAINT foo FOREIGN KEY (id1) REFERENCES tab2 (id2) DEFERRABLE INITIALLY DEFERRED

ALTER TABLE color ALTER COLUMN color_id ADD GENERATED BY DEFAULT AS IDENTITY
=
ALTER TABLE color ALTER COLUMN color_id ADD GENERATED BY DEFAULT AS IDENTITY;
:
{'semicolon_after_last_statement': True}

ALTER TABLE books
ADD CONSTRAINT distfk
FOREIGN KEY (author_id) REFERENCES authors (author_id) ON UPDATE RESTRICT NOT VALID
=
ALTER TABLE books ADD CONSTRAINT distfk FOREIGN KEY (author_id) REFERENCES authors (author_id) ON UPDATE RESTRICT NOT VALID;
:
{'semicolon_after_last_statement': True}

0 comments on commit cfdddfe

Please sign in to comment.