diff options
author | zhvv117 <[email protected]> | 2024-12-17 23:59:37 +0300 |
---|---|---|
committer | zhvv117 <[email protected]> | 2024-12-18 00:18:43 +0300 |
commit | 7b3da63dedb322aa58ae46599ddc43cfc2d6fa4d (patch) | |
tree | 9d74087c948e602125591e73f105588c214163a4 /yql/essentials/sql/v1/format/sql_format.cpp | |
parent | 91f4e7a8568d938839df80dfe34062f8900d438c (diff) |
YQL-19405: fix validation error in case of comment with \r at the end
commit_hash:4a061e3e5ade36adef410bca043268cb9064ec4d
Diffstat (limited to 'yql/essentials/sql/v1/format/sql_format.cpp')
-rw-r--r-- | yql/essentials/sql/v1/format/sql_format.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/yql/essentials/sql/v1/format/sql_format.cpp b/yql/essentials/sql/v1/format/sql_format.cpp index 3b3a14d850a..b330800734b 100644 --- a/yql/essentials/sql/v1/format/sql_format.cpp +++ b/yql/essentials/sql/v1/format/sql_format.cpp @@ -117,6 +117,12 @@ TStringBuf SkipQuotes(const TString& content) { return str; } +TStringBuf SkipNewline(const TString& content) { + TStringBuf str = content; + str.ChopSuffix("\n"); + return str; +} + bool Validate(const TParsedTokenList& query, const TParsedTokenList& formattedQuery) { auto in = query.begin(); auto out = formattedQuery.begin(); @@ -142,16 +148,7 @@ bool Validate(const TParsedTokenList& query, const TParsedTokenList& formattedQu return false; } } else if (inToken.Name == "COMMENT") { - TStringBuf inContent = inToken.Content; - TStringBuf outContent = outToken.Content; - - auto inNextToken = SkipWS(in + 1, inEnd); - if (inNextToken != inEnd && inNextToken->Name == "EOF") { - inContent.ChopSuffix("\n"); - outContent.ChopSuffix("\n"); - } - - if (inContent != outContent) { + if (SkipNewline(inToken.Content) != SkipNewline(outToken.Content)) { return false; } } else { |