Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](Planner) fix escape character when used in create view #45187

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ public boolean isMinValue() {

@Override
public String toSqlImpl() {
if (value.equals("\\")) {
value = "\\\\";
}
return "'" + value.replaceAll("'", "''") + "'";
Comment on lines +138 to 141
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we need a util to process string escape.
mysql doc: https://dev.mysql.com/doc/refman/8.4/en/string-literals.html

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ public void testBinaryPredicateConvertEsDsl() {
QueryBuilders.toEsDsl(stringNeExpr, column2typeMap).toJson());
}

@Test
public void testStringLiteralToSql() {
Expr escape = new StringLiteral("\\");
Assertions.assertEquals("'\\\\'", escape.toSql());
}

@Test
public void testCompoundPredicateConvertEsDsl() {
SlotRef k1 = new SlotRef(null, "k1");
Expand Down
Loading