提交 ba40896f authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Do not convert string to upper case in Parser.isKeyword()

上级 6e12ebd9
......@@ -154,7 +154,7 @@ public class DbContextRule implements Rule {
break;
}
String alias = up.substring(0, i);
if (ParserUtil.isKeyword(alias)) {
if (ParserUtil.isKeyword(alias, false)) {
break;
}
s = s.substring(alias.length());
......@@ -301,7 +301,7 @@ public class DbContextRule implements Rule {
return s;
}
String alias = up.substring(0, i);
if ("SET".equals(alias) || ParserUtil.isKeyword(alias)) {
if ("SET".equals(alias) || ParserUtil.isKeyword(alias, false)) {
return s;
}
if (newAlias) {
......
......@@ -4925,11 +4925,7 @@ public class Parser {
}
private boolean isKeyword(String s) {
if (!identifiersToUpper) {
// if not yet converted to uppercase, do it now
s = StringUtils.toUpperEnglish(s);
}
return ParserUtil.isKeyword(s);
return ParserUtil.isKeyword(s, !identifiersToUpper);
}
private Column parseColumnForTable(String columnName,
......
......@@ -235,14 +235,16 @@ public class ParserUtil {
* Checks if this string is a SQL keyword.
*
* @param s the token to check
* @param ignoreCase true if case should be ignored, false if only upper case
* tokens are detected as keywords
* @return true if it is a keyword
*/
public static boolean isKeyword(String s) {
public static boolean isKeyword(String s, boolean ignoreCase) {
int length = s.length();
if (length == 0) {
return false;
}
return getSaveTokenType(s, false, 0, length, false) != IDENTIFIER;
return getSaveTokenType(s, ignoreCase, 0, length, false) != IDENTIFIER;
}
/**
......@@ -278,7 +280,7 @@ public class ParserUtil {
* @param ignoreCase true if case should be ignored, false if only upper case
* tokens are detected as keywords
* @param start start index of token
* @param end index of token
* @param end index of token, exclusive; must be greater than start index
* @param additionalKeywords whether TOP, INTERSECTS, and "current data /
* time" functions are keywords
* @return the token type
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论