aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhvv117 <zhvv117@yandex-team.com>2024-12-10 22:42:11 +0300
committerzhvv117 <zhvv117@yandex-team.com>2024-12-10 22:59:27 +0300
commitc415f030b477653db847de5dbc58cb579267c1da (patch)
tree2c443bd0edd2f927aaa0223b8e1833718d971514
parentbcedee4e703dcb7dc36789e988c6a9b9b0219e7e (diff)
downloadydb-c415f030b477653db847de5dbc58cb579267c1da.tar.gz
fix additional newline after comment
commit_hash:63dc64fc9bf73bb1dd98c368466227fe72c5391c
-rw-r--r--yql/essentials/sql/v1/format/sql_format.cpp4
-rw-r--r--yql/essentials/sql/v1/format/sql_format_ut.h4
2 files changed, 7 insertions, 1 deletions
diff --git a/yql/essentials/sql/v1/format/sql_format.cpp b/yql/essentials/sql/v1/format/sql_format.cpp
index c029f6e3ad..f8e20849fd 100644
--- a/yql/essentials/sql/v1/format/sql_format.cpp
+++ b/yql/essentials/sql/v1/format/sql_format.cpp
@@ -562,6 +562,10 @@ private:
WriteComments(true);
}
+ if (AfterComment && Comments[LastComment - 1].Content.StartsWith("--")) {
+ return;
+ }
+
if (OutColumn) {
Out('\n');
}
diff --git a/yql/essentials/sql/v1/format/sql_format_ut.h b/yql/essentials/sql/v1/format/sql_format_ut.h
index 691cc8f8b7..7fe74f2d62 100644
--- a/yql/essentials/sql/v1/format/sql_format_ut.h
+++ b/yql/essentials/sql/v1/format/sql_format_ut.h
@@ -867,8 +867,10 @@ Y_UNIT_TEST(Select) {
"SELECT\n\t1\nLIMIT 10;\n"},
{"select 1 limit 10 offset 5",
"SELECT\n\t1\nLIMIT 10 OFFSET 5;\n"},
- { "select 1 union all select 2",
+ {"select 1 union all select 2",
"SELECT\n\t1\nUNION ALL\nSELECT\n\t2\n;\n" },
+ {"select * from $user where key == 1 -- comment",
+ "SELECT\n\t*\nFROM\n\t$user\nWHERE\n\tkey == 1 -- comment\n;\n"},
};
TSetup setup;