summaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/format/sql_format.cpp
diff options
context:
space:
mode:
authorzhvv117 <[email protected]>2024-12-13 19:30:08 +0300
committerzhvv117 <[email protected]>2024-12-13 20:29:52 +0300
commit8afd0e6dc9d41134a0cccfd6b6c5fe843efd80fb (patch)
tree23189019cfd74abfbc507c2a9e6d6fd58f360c6c /yql/essentials/sql/v1/format/sql_format.cpp
parent9eadcaf3657f3c430e7c845f68d80e3bbb5a2b4d (diff)
change double quotes to single quotes
commit_hash:7890ab16bc6488d4f13fd6ec6cd512107c0cba51
Diffstat (limited to 'yql/essentials/sql/v1/format/sql_format.cpp')
-rw-r--r--yql/essentials/sql/v1/format/sql_format.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/yql/essentials/sql/v1/format/sql_format.cpp b/yql/essentials/sql/v1/format/sql_format.cpp
index 8c4b04760f1..72007d15e27 100644
--- a/yql/essentials/sql/v1/format/sql_format.cpp
+++ b/yql/essentials/sql/v1/format/sql_format.cpp
@@ -87,6 +87,15 @@ TParsedToken TransformTokenForValidate(TParsedToken token) {
return token;
}
+TStringBuf SkipQuotes(const TString& content) {
+ TStringBuf str = content;
+ str.SkipPrefix("\"");
+ str.ChopSuffix("\"");
+ str.SkipPrefix("'");
+ str.ChopSuffix("'");
+ return str;
+}
+
bool Validate(const TParsedTokenList& query, const TParsedTokenList& formattedQuery) {
auto in = query.begin();
auto out = formattedQuery.begin();
@@ -105,6 +114,10 @@ bool Validate(const TParsedTokenList& query, const TParsedTokenList& formattedQu
if (!AsciiEqualsIgnoreCase(inToken.Content, outToken.Content)) {
return false;
}
+ } else if (inToken.Name == "STRING_VALUE") {
+ if (SkipQuotes(inToken.Content) != SkipQuotes(outToken.Content)) {
+ return false;
+ }
} else {
if (inToken.Content != outToken.Content) {
return false;
@@ -1698,6 +1711,13 @@ private:
}
}
+ if (ParsedTokens[TokenIndex].Name == "STRING_VALUE") {
+ TStringBuf checkStr = str;
+ if (checkStr.SkipPrefix("\"") && checkStr.ChopSuffix("\"") && !checkStr.Contains("'")) {
+ str = TStringBuilder() << '\'' << checkStr << '\'';
+ }
+ }
+
Out(str);
if (TokenIndex + 1 >= ParsedTokens.size() || ParsedTokens[TokenIndex + 1].Line > LastLine) {