From 74f3abc8ee8b500772c2b118d40df6fe53366a42 Mon Sep 17 00:00:00 2001 From: Lele Gaifax Date: Sat, 18 Jun 2022 12:53:19 +0200 Subject: [PATCH] Avoid spurious space in INSERT without explicit columns --- pglast/printers/dml.py | 2 +- tests/test_printers_prettification/dml/insert.sql | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pglast/printers/dml.py b/pglast/printers/dml.py index c7f67a38..ed2874ed 100644 --- a/pglast/printers/dml.py +++ b/pglast/printers/dml.py @@ -770,7 +770,7 @@ def insert_stmt(node, output): output.print_list(node.cols) output.write(')') else: - output.write(' ') + output.separator() if node.override: if node.override == enums.OverridingKind.OVERRIDING_USER_VALUE: output.write(' OVERRIDING USER VALUE ') diff --git a/tests/test_printers_prettification/dml/insert.sql b/tests/test_printers_prettification/dml/insert.sql index 522af2f9..3280442a 100644 --- a/tests/test_printers_prettification/dml/insert.sql +++ b/tests/test_printers_prettification/dml/insert.sql @@ -26,3 +26,9 @@ VALUES (1, 'this is short enough'), (2, 'this is too long, and will be splitted') : {'comma_at_eoln': True} + +insert into foo select * from bar += +INSERT INTO foo +SELECT * +FROM bar