Skip to content

Commit

Permalink
[CALCITE-6509] double quote everything
Browse files Browse the repository at this point in the history
  • Loading branch information
dssysolyatin committed Oct 10, 2024
1 parent 1ccd12e commit d441176
Showing 1 changed file with 0 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,31 +103,13 @@ static List<String> mongoFieldNames(final RelDataType rowType) {
}

static String maybeQuote(String s) {
if (!needsQuote(s)) {
return s;
}
return quote(s);
}

static String quote(String s) {
return "'" + s + "'"; // TODO: handle embedded quotes
}

private static boolean needsQuote(String s) {
if (!s.isEmpty()
&& (!Character.isJavaIdentifierStart(s.charAt(0)) || s.charAt(0) == '$')) {
return true;
}

for (int i = 1, n = s.length(); i < n; i++) {
char c = s.charAt(i);
if (!Character.isJavaIdentifierPart(c)) {
return true;
}
}
return false;
}

/** Translator from {@link RexNode} to strings in MongoDB's expression
* language. */
static class RexToMongoTranslator extends RexVisitorImpl<String> {
Expand Down

0 comments on commit d441176

Please sign in to comment.