From 746f291a619c4a792907c0dfa4a74eea5dae34f9 Mon Sep 17 00:00:00 2001 From: LY Date: Wed, 7 Aug 2024 15:05:22 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E5=A4=84=E7=90=86=E8=87=AA=E5=85=B3?= =?UTF-8?q?=E8=81=94=E6=9F=A5=E8=AF=A2=E6=97=B6=EF=BC=8C=E5=AF=B9Table:ali?= =?UTF-8?q?as=E7=9A=84=E5=86=99=E6=B3=95sql=E8=A1=A8=E5=90=8D=E6=8B=BC?= =?UTF-8?q?=E5=86=99=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/apijson/orm/AbstractSQLConfig.java | 106 +++++++++--------- 1 file changed, 56 insertions(+), 50 deletions(-) diff --git a/APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java b/APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java index 6b714e58..6131e3be 100755 --- a/APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java +++ b/APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java @@ -188,7 +188,7 @@ public abstract class AbstractSQLConfig implements SQLConfig(); + ALLOW_PARTIAL_UPDATE_FAIL_TABLE_MAP = new HashMap<>(); CONFIG_TABLE_LIST = new ArrayList<>(); // Table, Column 等是系统表 AbstractVerifier.SYSTEM_ACCESS_MAP.keySet()); CONFIG_TABLE_LIST.add(Function.class.getSimpleName()); @@ -492,8 +492,8 @@ public abstract class AbstractSQLConfig implements SQLConfig raw = getRaw(); - // 提前把 @having& 转为 @having,或者干脆不允许 @raw:"@having&" boolean containRaw = raw != null && (raw.contains(KEY_HAVING) || raw.contains(KEY_HAVING_AND)); + // 提前把 @having& 转为 @having,或者干脆不允许 @raw:"@having&" boolean containRaw = raw != null && (raw.contains(KEY_HAVING) || raw.contains(KEY_HAVING_AND)); boolean containRaw = raw != null && raw.contains(KEY_HAVING); // 直接把 having 类型从 Map 定改为 Map,避免额外拷贝 @@ -2657,12 +2663,12 @@ public String getLimitString() { } return getLimitString( - getPage() - , getCount() - , isOracle() || isSQLServer() || isDb2() - , isOracle() || isDameng() || isKingBase() - , isPresto() || isTrino() - ); + getPage() + , getCount() + , isOracle() || isSQLServer() || isDb2() + , isOracle() || isDameng() || isKingBase() + , isPresto() || isTrino() + ); } /**获取限制数量及偏移量 * @param page @@ -2672,7 +2678,7 @@ public String getLimitString() { * @return */ public static String getLimitString(int page, int count, boolean isTSQL, boolean isOracle) { - return getLimitString(page, count, isTSQL, isOracle, false); + return getLimitString(page, count, isTSQL, isOracle, false); } /**获取限制数量及偏移量 * @param page @@ -2685,17 +2691,17 @@ public static String getLimitString(int page, int count, boolean isTSQL, boolean public static String getLimitString(int page, int count, boolean isTSQL, boolean isOracle, boolean isPresto) { int offset = getOffset(page, count); - if (isOracle) { // TODO 判断版本,高版本可以用 OFFSET FETCH - return " WHERE ROWNUM BETWEEN " + offset + " AND " + (offset + count); - } + if (isOracle) { // TODO 判断版本,高版本可以用 OFFSET FETCH + return " WHERE ROWNUM BETWEEN " + offset + " AND " + (offset + count); + } if (isTSQL) { // OFFSET FECTH 中所有关键词都不可省略, 另外 Oracle 数据库使用子查询加 where 分页 return " OFFSET " + offset + " ROWS FETCH FIRST " + count + " ROWS ONLY"; } - if (isPresto) { // https://prestodb.io/docs/current/sql/select.html - return (offset <= 0 ? "" : " OFFSET " + offset) + " LIMIT " + count; - } + if (isPresto) { // https://prestodb.io/docs/current/sql/select.html + return (offset <= 0 ? "" : " OFFSET " + offset) + " LIMIT " + count; + } return " LIMIT " + count + (offset <= 0 ? "" : " OFFSET " + offset); // DELETE, UPDATE 不支持 OFFSET } @@ -3868,17 +3874,17 @@ public String getRegExpString(String key, String column, String value, boolean i if (isOracle() || isDameng() || isKingBase() || (isMySQL() && getDBVersionNums()[0] >= 8)) { return "regexp_like(" + getKey(column) + ", " + getValue(key, column, value) + (ignoreCase ? ", 'i'" : ", 'c'") + ")"; } - if (isPresto() || isTrino()) { - return "regexp_like(" + (ignoreCase ? "lower(" : "") + getKey(column) + (ignoreCase ? ")" : "") - + ", " + (ignoreCase ? "lower(" : "") + getValue(key, column, value) + (ignoreCase ? ")" : "") + ")"; - } + if (isPresto() || isTrino()) { + return "regexp_like(" + (ignoreCase ? "lower(" : "") + getKey(column) + (ignoreCase ? ")" : "") + + ", " + (ignoreCase ? "lower(" : "") + getValue(key, column, value) + (ignoreCase ? ")" : "") + ")"; + } if (isClickHouse()) { return "match(" + (ignoreCase ? "lower(" : "") + getKey(column) + (ignoreCase ? ")" : "") + ", " + (ignoreCase ? "lower(" : "") + getValue(key, column, value) + (ignoreCase ? ")" : "") + ")"; } - if (isElasticsearch()) { - return getKey(column) + " RLIKE " + getValue(key, column, value); - } + if (isElasticsearch()) { + return getKey(column) + " RLIKE " + getValue(key, column, value); + } if (isHive()) { return (ignoreCase ? "lower(" : "") + getKey(column) + (ignoreCase ? ")" : "") + " REGEXP " + (ignoreCase ? "lower(" : "") + getValue(key, column, value) + (ignoreCase ? ")" : ""); @@ -4135,7 +4141,7 @@ public String getExistsString(String key, String column, Object value, String ra /**WHERE key contains value * @param key * @param value - * @return {@link #getContainString(String, String, Object[], int)} + * @return {@link #getContainString(String, String, Object[], int)} * @throws NotExistException */ @JSONField(serialize = false) @@ -4196,11 +4202,11 @@ else if (isOracle() || isDameng() || isKingBase()) { condition += ("json_textcontains(" + getKey(column) + ", " + (StringUtil.isEmpty(path, true) ? "'$'" : getValue(key, column, path)) + ", " + getValue(key, column, c == null ? null : c.toString()) + ")"); } - else if (isPresto() || isTrino()) { - condition += ("json_array_contains(cast(" + getKey(column) + " AS VARCHAR), " + else if (isPresto() || isTrino()) { + condition += ("json_array_contains(cast(" + getKey(column) + " AS VARCHAR), " + getValue(key, column, c) + (StringUtil.isEmpty(path, true) ? "" : ", " + getValue(key, column, path)) + ")"); - } + } else { String v = c == null ? "null" : (c instanceof Boolean || c instanceof Number ? c.toString() : "\"" + c + "\""); if (isClickHouse()) { @@ -4613,7 +4619,7 @@ protected String getOraclePageSql(String sql) { } int offset = getOffset(getPage(), count); String alias = getAliasWithQuote(); - String quote = getQuote(); + String quote = getQuote(); return "SELECT * FROM (SELECT " + alias + ".*, ROWNUM "+ quote + "RN" + quote +" FROM (" + sql + ") " + alias + " WHERE ROWNUM <= " + (offset + count) + ") WHERE "+ quote + "RN" + quote +" > " + offset; } @@ -4816,7 +4822,7 @@ protected String concatJoinOn(@NotNull String sql, @NotNull String quote, @NotNu String rt = on.getRelateType(); if (StringUtil.isEmpty(rt, false)) { sql += (first ? ON : AND) + quote + jt + quote + "." + quote + on.getKey() + quote + (isNot ? " != " : " = ") - + quote + on.getTargetTable() + quote + "." + quote + on.getTargetKey() + quote; + + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote; } else { onJoinComplexRelation(sql, quote, j, jt, onList, on); @@ -4828,7 +4834,7 @@ protected String concatJoinOn(@NotNull String sql, @NotNull String quote, @NotNu } sql += (first ? ON : AND) + quote + jt + quote + "." + quote + on.getKey() + quote + " " + rt + " " - + quote + on.getTargetTable() + quote + "." + quote + on.getTargetKey() + quote; + + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote; } else if (rt.endsWith("$")) { String t = rt.substring(0, rt.length() - 1); @@ -4874,11 +4880,11 @@ else if (l > 0 && StringUtil.isName(String.valueOf(l))) { if (l <= 0 && r <= 0) { sql += (first ? ON : AND) + quote + jt + quote + "." + quote + on.getKey() + quote + (isNot ? NOT : "") - + " LIKE " + quote + on.getTargetTable() + quote + "." + quote + on.getTargetKey() + quote; + + " LIKE " + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote; } else { sql += (first ? ON : AND) + quote + jt + quote + "." + quote + on.getKey() + quote + (isNot ? NOT : "") - + (l <= 0 ? " LIKE concat(" : " LIKE concat('" + l + "', ") + quote + on.getTargetTable() + quote + + (l <= 0 ? " LIKE concat(" : " LIKE concat('" + l + "', ") + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote + (r <= 0 ? ")" : ", '" + r + "')"); } } @@ -4887,38 +4893,38 @@ else if (rt.endsWith("~")) { if (isPostgreSQL() || isInfluxDB()) { sql += (first ? ON : AND) + quote + jt + quote + "." + quote + on.getKey() + quote + (isNot ? NOT : "") + " ~" + (ignoreCase ? "* " : " ") - + quote + on.getTargetTable() + quote + "." + quote + on.getTargetKey() + quote; + + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote; } else if (isOracle() || isDameng() || isKingBase()) { sql += (first ? ON : AND) + "regexp_like(" + quote + jt + quote + "." + quote + on.getKey() + quote - + ", " + quote + on.getTargetTable() + quote + "." + quote + on.getTargetKey() + quote + + ", " + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote + (ignoreCase ? ", 'i'" : ", 'c'") + ")"; } - else if (isPresto() || isTrino()) { - sql += (first ? ON : AND) + "regexp_like(" + (ignoreCase ? "lower(" : "") + quote + else if (isPresto() || isTrino()) { + sql += (first ? ON : AND) + "regexp_like(" + (ignoreCase ? "lower(" : "") + quote + jt + quote + "." + quote + on.getKey() + quote + (ignoreCase ? ")" : "") - + ", " + (ignoreCase ? "lower(" : "") + quote + on.getTargetTable() + + ", " + (ignoreCase ? "lower(" : "") + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote + (ignoreCase ? ")" : "") + ")"; - } + } else if (isClickHouse()) { sql += (first ? ON : AND) + "match(" + (ignoreCase ? "lower(" : "") + quote + jt + quote + "." + quote + on.getKey() + quote + (ignoreCase ? ")" : "") - + ", " + (ignoreCase ? "lower(" : "") + quote + on.getTargetTable() + + ", " + (ignoreCase ? "lower(" : "") + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote + (ignoreCase ? ")" : "") + ")"; } else if (isElasticsearch()) { - sql += (first ? ON : AND) + quote + jt + quote + "." + quote + on.getKey() + quote + (isNot ? NOT : "") - + " RLIKE " + quote + on.getTargetTable() + quote + "." + quote + on.getTargetKey() + quote; - } + sql += (first ? ON : AND) + quote + jt + quote + "." + quote + on.getKey() + quote + (isNot ? NOT : "") + + " RLIKE " + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote; + } else if (isHive()) { - sql += (first ? ON : AND) + (ignoreCase ? "lower(" : "") + quote + jt + quote + "." + quote + on.getKey() + quote + (ignoreCase ? ")" : "") - + " REGEXP " + (ignoreCase ? "lower(" : "") + quote + on.getTargetTable() + sql += (first ? ON : AND) + (ignoreCase ? "lower(" : "") + quote + jt + quote + "." + quote + on.getKey() + quote + (ignoreCase ? ")" : "") + + " REGEXP " + (ignoreCase ? "lower(" : "") + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote + (ignoreCase ? ")" : ""); - } + } else { - sql += (first ? ON : AND) + quote + jt + quote + "." + quote + on.getKey() + quote + (isNot ? NOT : "") + sql += (first ? ON : AND) + quote + jt + quote + "." + quote + on.getKey() + quote + (isNot ? NOT : "") + " REGEXP " + (ignoreCase ? "" : "BINARY ") - + quote + on.getTargetTable() + quote + "." + quote + on.getTargetKey() + quote; + + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote; } } else if ("{}".equals(rt) || "<>".equals(rt)) { @@ -4950,12 +4956,12 @@ else if ("{}".equals(rt) || "<>".equals(rt)) { String arrKeyPath; String itemKeyPath; if ("{}".equals(rt)) { - arrKeyPath = quote + on.getTargetTable() + quote + "." + quote + on.getTargetKey() + quote; + arrKeyPath = quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote; itemKeyPath = quote + jt + quote + "." + quote + on.getKey() + quote; } else { arrKeyPath = quote + jt + quote + "." + quote + on.getKey() + quote; - itemKeyPath = quote + on.getTargetTable() + quote + "." + quote + on.getTargetKey() + quote; + itemKeyPath = quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote; } if (isPostgreSQL() || isInfluxDB()) { //operator does not exist: jsonb @> character varying "[" + c + "]"); From 6bfb21840d8b9152dc1131d1cd8ba7c0a9137de6 Mon Sep 17 00:00:00 2001 From: TommyLemon <1184482681@qq.com> Date: Sun, 11 Aug 2024 17:08:25 +0800 Subject: [PATCH 2/2] =?UTF-8?q?getSQLTableWithAlias=20=E5=B8=A6=E4=B8=8A?= =?UTF-8?q?=E5=8E=9F=E8=A1=A8=E5=90=8D=EF=BC=8C=E9=81=BF=E5=85=8D=20alias?= =?UTF-8?q?=20=E4=B8=8E=E5=85=B6=E5=AE=83=E8=A1=A8=E5=90=8D/=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=20=E5=86=B2=E7=AA=81=EF=BC=9B=E4=BC=98=E5=8C=96=20Git?= =?UTF-8?q?Hub=20=E5=AF=B9=20tab=20=E5=92=8C=20IDE=20=E5=A4=84=E7=90=86?= =?UTF-8?q?=E4=B8=8D=E4=B8=80=E8=87=B4=E5=AF=BC=E8=87=B4=E7=BC=A9=E8=BF=9B?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/apijson/orm/AbstractSQLConfig.java | 104 +++++++++--------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java b/APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java index 6131e3be..5014f0eb 100755 --- a/APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java +++ b/APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java @@ -143,9 +143,9 @@ public abstract class AbstractSQLConfig implements SQLConfig COLUMN_KEY_MAP; - /** - * 允许批量增删改部分记录失败的表 - */ + /** + * 允许批量增删改部分记录失败的表 + */ public static Map ALLOW_PARTIAL_UPDATE_FAIL_TABLE_MAP; public static List CONFIG_TABLE_LIST; public static List DATABASE_LIST; @@ -188,7 +188,7 @@ public abstract class AbstractSQLConfig implements SQLConfig(); + ALLOW_PARTIAL_UPDATE_FAIL_TABLE_MAP = new HashMap<>(); CONFIG_TABLE_LIST = new ArrayList<>(); // Table, Column 等是系统表 AbstractVerifier.SYSTEM_ACCESS_MAP.keySet()); CONFIG_TABLE_LIST.add(Function.class.getSimpleName()); @@ -492,8 +492,8 @@ public abstract class AbstractSQLConfig implements SQLConfig= 8)) { return "regexp_like(" + getKey(column) + ", " + getValue(key, column, value) + (ignoreCase ? ", 'i'" : ", 'c'") + ")"; } - if (isPresto() || isTrino()) { - return "regexp_like(" + (ignoreCase ? "lower(" : "") + getKey(column) + (ignoreCase ? ")" : "") + if (isPresto() || isTrino()) { + return "regexp_like(" + (ignoreCase ? "lower(" : "") + getKey(column) + (ignoreCase ? ")" : "") + ", " + (ignoreCase ? "lower(" : "") + getValue(key, column, value) + (ignoreCase ? ")" : "") + ")"; - } + } if (isClickHouse()) { return "match(" + (ignoreCase ? "lower(" : "") + getKey(column) + (ignoreCase ? ")" : "") + ", " + (ignoreCase ? "lower(" : "") + getValue(key, column, value) + (ignoreCase ? ")" : "") + ")"; } - if (isElasticsearch()) { - return getKey(column) + " RLIKE " + getValue(key, column, value); - } + if (isElasticsearch()) { + return getKey(column) + " RLIKE " + getValue(key, column, value); + } if (isHive()) { return (ignoreCase ? "lower(" : "") + getKey(column) + (ignoreCase ? ")" : "") + " REGEXP " + (ignoreCase ? "lower(" : "") + getValue(key, column, value) + (ignoreCase ? ")" : ""); @@ -4202,11 +4202,11 @@ else if (isOracle() || isDameng() || isKingBase()) { condition += ("json_textcontains(" + getKey(column) + ", " + (StringUtil.isEmpty(path, true) ? "'$'" : getValue(key, column, path)) + ", " + getValue(key, column, c == null ? null : c.toString()) + ")"); } - else if (isPresto() || isTrino()) { - condition += ("json_array_contains(cast(" + getKey(column) + " AS VARCHAR), " + else if (isPresto() || isTrino()) { + condition += ("json_array_contains(cast(" + getKey(column) + " AS VARCHAR), " + getValue(key, column, c) + (StringUtil.isEmpty(path, true) ? "" : ", " + getValue(key, column, path)) + ")"); - } + } else { String v = c == null ? "null" : (c instanceof Boolean || c instanceof Number ? c.toString() : "\"" + c + "\""); if (isClickHouse()) { @@ -4619,7 +4619,7 @@ protected String getOraclePageSql(String sql) { } int offset = getOffset(getPage(), count); String alias = getAliasWithQuote(); - String quote = getQuote(); + String quote = getQuote(); return "SELECT * FROM (SELECT " + alias + ".*, ROWNUM "+ quote + "RN" + quote +" FROM (" + sql + ") " + alias + " WHERE ROWNUM <= " + (offset + count) + ") WHERE "+ quote + "RN" + quote +" > " + offset; } @@ -4796,10 +4796,10 @@ public String getJoinString() throws Exception { //if (changed) { - // List opvl = getPreparedValueList(); - // if (opvl != null && opvl.isEmpty() == false) { - // pvl.addAll(opvl); - // } + // List opvl = getPreparedValueList(); + // if (opvl != null && opvl.isEmpty() == false) { + // pvl.addAll(opvl); + // } setPreparedValueList(pvl); //} @@ -4822,7 +4822,7 @@ protected String concatJoinOn(@NotNull String sql, @NotNull String quote, @NotNu String rt = on.getRelateType(); if (StringUtil.isEmpty(rt, false)) { sql += (first ? ON : AND) + quote + jt + quote + "." + quote + on.getKey() + quote + (isNot ? " != " : " = ") - + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote; + + quote + getSQLTableWithAlias(on.getTargetTable(), on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote; } else { onJoinComplexRelation(sql, quote, j, jt, onList, on); @@ -4834,7 +4834,7 @@ protected String concatJoinOn(@NotNull String sql, @NotNull String quote, @NotNu } sql += (first ? ON : AND) + quote + jt + quote + "." + quote + on.getKey() + quote + " " + rt + " " - + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote; + + quote + getSQLTableWithAlias(on.getTargetTable(), on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote; } else if (rt.endsWith("$")) { String t = rt.substring(0, rt.length() - 1); @@ -4880,11 +4880,11 @@ else if (l > 0 && StringUtil.isName(String.valueOf(l))) { if (l <= 0 && r <= 0) { sql += (first ? ON : AND) + quote + jt + quote + "." + quote + on.getKey() + quote + (isNot ? NOT : "") - + " LIKE " + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote; + + " LIKE " + quote + getSQLTableWithAlias(on.getTargetTable(), on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote; } else { sql += (first ? ON : AND) + quote + jt + quote + "." + quote + on.getKey() + quote + (isNot ? NOT : "") - + (l <= 0 ? " LIKE concat(" : " LIKE concat('" + l + "', ") + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + + (l <= 0 ? " LIKE concat(" : " LIKE concat('" + l + "', ") + quote + getSQLTableWithAlias(on.getTargetTable(), on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote + (r <= 0 ? ")" : ", '" + r + "')"); } } @@ -4893,38 +4893,38 @@ else if (rt.endsWith("~")) { if (isPostgreSQL() || isInfluxDB()) { sql += (first ? ON : AND) + quote + jt + quote + "." + quote + on.getKey() + quote + (isNot ? NOT : "") + " ~" + (ignoreCase ? "* " : " ") - + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote; + + quote + getSQLTableWithAlias(on.getTargetTable(), on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote; } else if (isOracle() || isDameng() || isKingBase()) { sql += (first ? ON : AND) + "regexp_like(" + quote + jt + quote + "." + quote + on.getKey() + quote - + ", " + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote + + ", " + quote + getSQLTableWithAlias(on.getTargetTable(), on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote + (ignoreCase ? ", 'i'" : ", 'c'") + ")"; } - else if (isPresto() || isTrino()) { - sql += (first ? ON : AND) + "regexp_like(" + (ignoreCase ? "lower(" : "") + quote + else if (isPresto() || isTrino()) { + sql += (first ? ON : AND) + "regexp_like(" + (ignoreCase ? "lower(" : "") + quote + jt + quote + "." + quote + on.getKey() + quote + (ignoreCase ? ")" : "") - + ", " + (ignoreCase ? "lower(" : "") + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + + ", " + (ignoreCase ? "lower(" : "") + quote + getSQLTableWithAlias(on.getTargetTable(), on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote + (ignoreCase ? ")" : "") + ")"; - } + } else if (isClickHouse()) { sql += (first ? ON : AND) + "match(" + (ignoreCase ? "lower(" : "") + quote + jt + quote + "." + quote + on.getKey() + quote + (ignoreCase ? ")" : "") - + ", " + (ignoreCase ? "lower(" : "") + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + + ", " + (ignoreCase ? "lower(" : "") + quote + getSQLTableWithAlias(on.getTargetTable(), on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote + (ignoreCase ? ")" : "") + ")"; } else if (isElasticsearch()) { - sql += (first ? ON : AND) + quote + jt + quote + "." + quote + on.getKey() + quote + (isNot ? NOT : "") - + " RLIKE " + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote; - } + sql += (first ? ON : AND) + quote + jt + quote + "." + quote + on.getKey() + quote + (isNot ? NOT : "") + + " RLIKE " + quote + getSQLTableWithAlias(on.getTargetTable(), on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote; + } else if (isHive()) { - sql += (first ? ON : AND) + (ignoreCase ? "lower(" : "") + quote + jt + quote + "." + quote + on.getKey() + quote + (ignoreCase ? ")" : "") - + " REGEXP " + (ignoreCase ? "lower(" : "") + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + sql += (first ? ON : AND) + (ignoreCase ? "lower(" : "") + quote + jt + quote + "." + quote + on.getKey() + quote + (ignoreCase ? ")" : "") + + " REGEXP " + (ignoreCase ? "lower(" : "") + quote + getSQLTableWithAlias(on.getTargetTable(), on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote + (ignoreCase ? ")" : ""); - } + } else { - sql += (first ? ON : AND) + quote + jt + quote + "." + quote + on.getKey() + quote + (isNot ? NOT : "") + sql += (first ? ON : AND) + quote + jt + quote + "." + quote + on.getKey() + quote + (isNot ? NOT : "") + " REGEXP " + (ignoreCase ? "" : "BINARY ") - + quote + getSQLTableWithAlias(on.getTargetTable(),on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote; + + quote + getSQLTableWithAlias(on.getTargetTable(), on.getTargetAlias()) + quote + "." + quote + on.getTargetKey() + quote; } } else if ("{}".equals(rt) || "<>".equals(rt)) {