From 06c1979b97235ab5cbe1de5f4cb5a407046ffff9 Mon Sep 17 00:00:00 2001 From: terrymanu Date: Wed, 17 Jan 2018 18:52:46 +0800 Subject: [PATCH] for #567 --- .../io/shardingjdbc/core/util/SQLUtil.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) 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; } }