#12037 Use dialect to validate identifier

上级 0b039daf
......@@ -118,7 +118,7 @@ public class HANASQLDialect extends GenericSQLDialect implements TPRuleProvider
@Override
public void extendRules(@Nullable DBPDataSourceContainer dataSource, @NotNull List<TPRule> rules, @NotNull RulePosition position) {
if (position == RulePosition.INITIAL) {
rules.add(new SQLVariableRule());
rules.add(new SQLVariableRule(this));
}
}
}
......@@ -306,7 +306,7 @@ public class SQLServerDialect extends JDBCSQLDialect implements TPRuleProvider {
@Override
public void extendRules(@Nullable DBPDataSourceContainer dataSource, @NotNull List<TPRule> rules, @NotNull RulePosition position) {
if (position == RulePosition.INITIAL) {
rules.add(new SQLVariableRule());
rules.add(new SQLVariableRule(this));
}
if (position == RulePosition.KEYWORDS) {
final TPTokenDefault keywordToken = new TPTokenDefault(SQLTokenType.T_KEYWORD);
......
......@@ -16,6 +16,8 @@
*/
package org.jkiss.dbeaver.model.sql.parser.rules;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.model.sql.SQLDialect;
import org.jkiss.dbeaver.model.sql.parser.tokens.SQLVariableToken;
import org.jkiss.dbeaver.model.text.parser.TPCharacterScanner;
import org.jkiss.dbeaver.model.text.parser.TPPredicateRule;
......@@ -27,7 +29,13 @@ import org.jkiss.dbeaver.model.text.parser.TPTokenAbstract;
*/
public class SQLVariableRule implements TPPredicateRule {
private final TPToken token = new SQLVariableToken();
private final SQLDialect dialect;
private final TPToken token;
public SQLVariableRule(@NotNull SQLDialect dialect) {
this.dialect = dialect;
this.token = new SQLVariableToken();
}
@Override
public TPToken getSuccessToken() {
......@@ -41,7 +49,7 @@ public class SQLVariableRule implements TPPredicateRule {
int ch = scanner.read();
int read = 0;
if (!Character.isJavaIdentifierPart(ch)) {
if (!dialect.validIdentifierPart((char) ch, false)) {
ch = scanner.read();
read++;
......@@ -49,7 +57,7 @@ public class SQLVariableRule implements TPPredicateRule {
do {
ch = scanner.read();
read++;
} while (Character.isJavaIdentifierPart(ch));
} while (dialect.validIdentifierPart((char) ch, false));
if (read > 2) {
scanner.unread();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册