mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bugfix
This commit is contained in:
@@ -234,7 +234,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
String chars = lexer.stringVal();
|
||||
concat.addParameter(new SQLCharExpr(chars));
|
||||
lexer.nextToken();
|
||||
} while (lexer.token() == Token.LITERAL_CHARS);
|
||||
} while (lexer.token() == Token.LITERAL_CHARS || lexer.token() == Token.LITERAL_ALIAS);
|
||||
expr = concat;
|
||||
}
|
||||
} else if (lexer.token() == Token.IDENTIFIER) {
|
||||
|
||||
@@ -2205,6 +2205,7 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
item.setParent(x);
|
||||
item.accept(this);
|
||||
}
|
||||
print(";");
|
||||
|
||||
decrementIndent();
|
||||
return false;
|
||||
@@ -2226,6 +2227,7 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
item.setParent(x);
|
||||
item.accept(this);
|
||||
}
|
||||
print(";");
|
||||
|
||||
decrementIndent();
|
||||
return false;
|
||||
@@ -2256,6 +2258,7 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
println();
|
||||
}
|
||||
}
|
||||
print(";");
|
||||
decrementIndent();
|
||||
|
||||
for (ElseIf elseIf : x.getElseIfList()) {
|
||||
|
||||
@@ -18,4 +18,15 @@ public class SQLUtilsTest extends TestCase {
|
||||
"\nFROM t" + //
|
||||
"\nWHERE id = 'abc'", formattedSql);
|
||||
}
|
||||
|
||||
public void test_format_1() throws Exception {
|
||||
String sql = "select * from t where tname LIKE \"%\"'温'\"%\"";
|
||||
String formattedSql = SQLUtils.formatMySql(sql);
|
||||
Assert.assertEquals("SELECT *\nFROM t\nWHERE tname LIKE CONCAT('%', '温', '%')", formattedSql);
|
||||
}
|
||||
|
||||
public void test_format_2() throws Exception {
|
||||
String sql = "begin\n" + " if (a=10) then\n" + " null;\n" + " else\n" + " null;\n" + " end if;\n" + "end;";
|
||||
System.out.println(SQLUtils.formatOracle(sql));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user