aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials
diff options
context:
space:
mode:
authorzhvv117 <zhvv117@yandex-team.com>2024-12-10 22:42:11 +0300
committerVitaly Isaev <vitalyisaev@ydb.tech>2024-12-12 10:12:03 +0000
commit8234b082f2230b2f562dc1a474c9bacd6f50e808 (patch)
treee0b3f0f69bad6cafc1adf9bb30601e83f6f96eae /yql/essentials
parent4d758beeece453d92aca80c46f503d27271e07f2 (diff)
downloadydb-8234b082f2230b2f562dc1a474c9bacd6f50e808.tar.gz
fix additional newline after comment
commit_hash:63dc64fc9bf73bb1dd98c368466227fe72c5391c
Diffstat (limited to 'yql/essentials')
-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;