mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved odps sql parser. bug fixed for issue #1375
This commit is contained in:
@@ -352,4 +352,8 @@ public class OdpsLexer extends Lexer {
|
||||
protected final void scanString() {
|
||||
scanString2();
|
||||
}
|
||||
|
||||
protected final void scanAlias() {
|
||||
scanAlias2();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -881,10 +881,31 @@ public class OdpsOutputVisitor extends SQLASTOutputVisitor implements OdpsASTVis
|
||||
if (text == null) {
|
||||
print0(ucase ? "NULL" : "null");
|
||||
} else {
|
||||
print('\'');
|
||||
String text2 = text.replaceAll("\\'", "\\\\'");
|
||||
print0(text2);
|
||||
print('\'');
|
||||
StringBuilder buf = new StringBuilder(text.length() + 2);
|
||||
buf.append('\'');
|
||||
for (int i = 0; i < text.length(); ++i) {
|
||||
char ch = text.charAt(i);
|
||||
switch (ch) {
|
||||
case '\\':
|
||||
buf.append("\\\\");
|
||||
break;
|
||||
case '\'':
|
||||
buf.append("\\'");
|
||||
break;
|
||||
case '\0':
|
||||
buf.append("\\0");
|
||||
break;
|
||||
case '\n':
|
||||
buf.append("\\n");
|
||||
break;
|
||||
default:
|
||||
buf.append(ch);
|
||||
break;
|
||||
}
|
||||
}
|
||||
buf.append('\'');
|
||||
|
||||
print0(buf.toString());
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user