From 409c024c88704e88fc20ddcb31ec6f425a812558 Mon Sep 17 00:00:00 2001 From: haocao Date: Wed, 17 Jan 2018 13:24:51 +0800 Subject: [PATCH] Refactor keywords. --- .../core/parsing/lexer/dialect/mysql/MySQLKeyword.java | 4 +--- .../core/parsing/lexer/dialect/oracle/OracleKeyword.java | 1 - .../parsing/lexer/dialect/postgresql/PostgreSQLKeyword.java | 4 ++-- .../parsing/lexer/dialect/sqlserver/SQLServerKeyword.java | 1 + .../shardingjdbc/core/parsing/lexer/token/DefaultKeyword.java | 2 -- .../core/parsing/parser/clause/OrderByClauseParser.java | 3 ++- 6 files changed, 6 insertions(+), 9 deletions(-) diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/lexer/dialect/mysql/MySQLKeyword.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/lexer/dialect/mysql/MySQLKeyword.java index 1529645aa489d..d66726bd94342 100755 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/lexer/dialect/mysql/MySQLKeyword.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/lexer/dialect/mysql/MySQLKeyword.java @@ -54,7 +54,6 @@ public enum MySQLKeyword implements Keyword { FIRST, SPATIAL, ALGORITHM, - CHARACTER, COLLATE, DISCARD, IMPORT, @@ -93,6 +92,5 @@ public enum MySQLKeyword implements Keyword { ROLLUP, RESTRICT, STRAIGHT_JOIN, - REGEXP, - KEY + REGEXP } diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/lexer/dialect/oracle/OracleKeyword.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/lexer/dialect/oracle/OracleKeyword.java index c569b10495dec..99c85288909fa 100755 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/lexer/dialect/oracle/OracleKeyword.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/lexer/dialect/oracle/OracleKeyword.java @@ -36,7 +36,6 @@ public enum OracleKeyword implements Keyword { MERGE, PURGE, ROWS, - IF, GOTO, ONLY, AUTOMATIC, diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/lexer/dialect/postgresql/PostgreSQLKeyword.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/lexer/dialect/postgresql/PostgreSQLKeyword.java index d477aab8cc9cb..6de33c7cf1cea 100755 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/lexer/dialect/postgresql/PostgreSQLKeyword.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/lexer/dialect/postgresql/PostgreSQLKeyword.java @@ -34,7 +34,6 @@ public enum PostgreSQLKeyword implements Keyword { LAST, LIMIT, OFFSET, - SIBLINGS, RESTART, RECURSIVE, CURRENT, @@ -65,5 +64,6 @@ public enum PostgreSQLKeyword implements Keyword { DEFERRABLE, INITIALLY, DEFERRED, - IMMEDIATE + IMMEDIATE, + EXTRACT } diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/lexer/dialect/sqlserver/SQLServerKeyword.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/lexer/dialect/sqlserver/SQLServerKeyword.java index a49a0d18c5d6e..ff5dc78a42a4c 100755 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/lexer/dialect/sqlserver/SQLServerKeyword.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/lexer/dialect/sqlserver/SQLServerKeyword.java @@ -48,5 +48,6 @@ public enum SQLServerKeyword implements Keyword { APPLY, REDUCE, REPLICATE, + EXTRACT, REDISTRIBUTE } diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/lexer/token/DefaultKeyword.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/lexer/token/DefaultKeyword.java index a9f61c5b594c2..15147d6019753 100755 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/lexer/token/DefaultKeyword.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/lexer/token/DefaultKeyword.java @@ -172,7 +172,6 @@ public enum DefaultKeyword implements Keyword { INOUT, OVER, ADVISE, - SIBLINGS, LOOP, EXPLAIN, DEFAULT, @@ -239,7 +238,6 @@ public enum DefaultKeyword implements Keyword { ROUND, TRUNC, POSITION, - EXTRACT, LENGTH, CHAR_LENGTH, SUBSTRING, diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/OrderByClauseParser.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/OrderByClauseParser.java index 7de5c8ce36b22..f3e2371e4d999 100644 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/OrderByClauseParser.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/parsing/parser/clause/OrderByClauseParser.java @@ -2,6 +2,7 @@ import io.shardingjdbc.core.constant.OrderType; import io.shardingjdbc.core.parsing.lexer.LexerEngine; +import io.shardingjdbc.core.parsing.lexer.dialect.oracle.OracleKeyword; import io.shardingjdbc.core.parsing.lexer.token.DefaultKeyword; import io.shardingjdbc.core.parsing.lexer.token.Symbol; import io.shardingjdbc.core.parsing.parser.clause.expression.BasicExpressionParser; @@ -47,7 +48,7 @@ public final void parse(final SelectStatement selectStatement) { return; } List result = new LinkedList<>(); - lexerEngine.skipIfEqual(DefaultKeyword.SIBLINGS); + lexerEngine.skipIfEqual(OracleKeyword.SIBLINGS); lexerEngine.accept(DefaultKeyword.BY); do { result.add(parseSelectOrderByItem(selectStatement));