Skip to content

Commit

Permalink
[Partial Backport] partially backport CALCITE-3823 to make quoteIdent… (
Browse files Browse the repository at this point in the history
#97)

* [Partial Backport] partially backport CALCITE-3823 to make quoteIdentifier use identifierNeedsQuote()

* update
  • Loading branch information
rzhang10 authored Nov 7, 2023
1 parent 1b04e27 commit 912bb67
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions core/src/main/java/org/apache/calcite/sql/SqlDialect.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,7 @@ public RelDataTypeSystem getTypeSystem() {
* @return Quoted identifier
*/
public String quoteIdentifier(String val) {
if (identifierQuoteString == null) {
return val; // quoting is not supported
}
String val2 =
val.replaceAll(
identifierEndQuoteString,
identifierEscapedQuote);
return identifierQuoteString + val2 + identifierEndQuoteString;
return quoteIdentifier(new StringBuilder(), val).toString();
}

/**
Expand All @@ -360,15 +353,13 @@ public StringBuilder quoteIdentifier(
StringBuilder buf,
String val) {
if (identifierQuoteString == null // quoting is not supported
|| identifierEndQuoteString == null
|| identifierEscapedQuote == null
|| !identifierNeedsQuote(val)) {
buf.append(val);
} else {
String val2 =
val.replaceAll(
identifierEndQuoteString,
identifierEscapedQuote);
buf.append(identifierQuoteString);
buf.append(val2);
buf.append(val.replace(identifierEndQuoteString, identifierEscapedQuote));
buf.append(identifierEndQuoteString);
}
return buf;
Expand Down

0 comments on commit 912bb67

Please sign in to comment.