diff --git a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/util/SQLUtil.java b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/util/SQLUtil.java index 239d05e298c25..fd8630773e7a6 100644 --- a/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/util/SQLUtil.java +++ b/sharding-jdbc-core/src/main/java/io/shardingjdbc/core/util/SQLUtil.java @@ -52,15 +52,23 @@ public static String getExactlyValue(final String value) { * @return original SQL expression */ public static String getOriginalValue(final String value, final DatabaseType databaseType) { - if (DatabaseType.MySQL == databaseType) { - try { - DefaultKeyword.valueOf(value.toUpperCase()); - MySQLKeyword.valueOf(value.toUpperCase()); - return String.format("`%s`", value); - } catch (final IllegalArgumentException ex) { - return value; - } + if (DatabaseType.MySQL != databaseType) { + return value; + } + try { + DefaultKeyword.valueOf(value.toUpperCase()); + return String.format("`%s`", value); + } catch (final IllegalArgumentException ex) { + return getOriginalValueForMySQLKeyword(value); + } + } + + private static String getOriginalValueForMySQLKeyword(final String value) { + try { + MySQLKeyword.valueOf(value.toUpperCase()); + return String.format("`%s`", value); + } catch (final IllegalArgumentException ex) { + return value; } - return value; } }