@@ -600,10 +600,10 @@ public String getOrderString(boolean hasPrefix) {
600
600
601
601
String order = StringUtil .getTrimedString (getOrder ());
602
602
603
- if (isOracle () || isSQLServer ()) { // Oracle 和 SQL Server 的 OFFSET 必须加 ORDER BY
603
+ if (getCount () > 0 && ( isOracle () || isSQLServer () )) { // Oracle 和 SQL Server 的 OFFSET 必须加 ORDER BY
604
604
605
605
// String[] ss = StringUtil.split(order);
606
- if (StringUtil .isEmpty (order , true )) {
606
+ if (StringUtil .isEmpty (order , true )) { //SQL Server 子查询内必须指定 OFFSET 才能用 ORDER BY
607
607
String idKey = getIdKey ();
608
608
if (StringUtil .isEmpty (idKey , true )) {
609
609
idKey = "id" ; //ORDER BY NULL 不行,SQL Server 会报错,必须要有排序,才能使用 OFFSET FETCH,如果没有 idKey,请求中指定 @order 即可
@@ -1657,6 +1657,9 @@ public String getRegExpString(String key, String value, boolean ignoreCase) {
1657
1657
if (isPostgreSQL ()) {
1658
1658
return getKey (key ) + " ~" + (ignoreCase ? "* " : " " ) + getValue (value );
1659
1659
}
1660
+ if (isOracle ()) {
1661
+ return "regexp_like(" + getKey (key ) + ", " + getValue (value ) + (ignoreCase ? ", 'i'" : ", 'c'" ) + ")" ;
1662
+ }
1660
1663
return getKey (key ) + " REGEXP " + (ignoreCase ? "" : "BINARY " ) + getValue (value );
1661
1664
}
1662
1665
//~ regexp >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -1889,12 +1892,15 @@ public String getContainString(String key, Object[] childs, int type) throws Ill
1889
1892
throw new IllegalArgumentException (key + "<>:value 中value类型不能为JSON!" );
1890
1893
}
1891
1894
1895
+ condition += (i <= 0 ? "" : (Logic .isAnd (type ) ? AND : OR ));
1892
1896
if (isPostgreSQL ()) {
1893
- condition += (i <= 0 ? "" : (Logic .isAnd (type ) ? AND : OR ))
1894
- + getKey (key ) + " @> " + getValue (newJSONArray (childs [i ])); //operator does not exist: jsonb @> character varying "[" + childs[i] + "]");
1895
- } else {
1896
- condition += (i <= 0 ? "" : (Logic .isAnd (type ) ? AND : OR ))
1897
- + "json_contains(" + getKey (key ) + ", " + getValue (childs [i ].toString ()) + ")" ;
1897
+ condition += (getKey (key ) + " @> " + getValue (newJSONArray (childs [i ]))); //operator does not exist: jsonb @> character varying "[" + childs[i] + "]");
1898
+ }
1899
+ else if (isOracle ()) {
1900
+ condition += ("json_textcontains(" + getKey (key ) + ", '$', " + getValue (childs [i ].toString ()) + ")" );
1901
+ }
1902
+ else {
1903
+ condition += ("json_contains(" + getKey (key ) + ", " + getValue (childs [i ].toString ()) + ")" );
1898
1904
}
1899
1905
}
1900
1906
}
@@ -2004,7 +2010,7 @@ public String getSetString(RequestMethod method, Map<String, Object> content, bo
2004
2010
value = content .get (key );
2005
2011
key = getRealKey (method , key , false , true , verifyName , quote );
2006
2012
2007
- setString += (isFirst ? "" : ", " ) + (getKey (key ) + "= " + (keyType == 1 ? getAddString (key , value ) : (keyType == 2
2013
+ setString += (isFirst ? "" : ", " ) + (getKey (key ) + " = " + (keyType == 1 ? getAddString (key , value ) : (keyType == 2
2008
2014
? getRemoveString (key , value ) : getValue (value )) ) );
2009
2015
2010
2016
isFirst = false ;
@@ -2017,10 +2023,10 @@ public String getSetString(RequestMethod method, Map<String, Object> content, bo
2017
2023
return " SET " + setString ;
2018
2024
}
2019
2025
2020
- /**SET key = CONCAT (key, 'value')
2026
+ /**SET key = concat (key, 'value')
2021
2027
* @param key
2022
2028
* @param value
2023
- * @return CONCAT (key, 'value')
2029
+ * @return concat (key, 'value')
2024
2030
* @throws IllegalArgumentException
2025
2031
*/
2026
2032
@ JSONField (serialize = false )
@@ -2029,7 +2035,7 @@ public String getAddString(String key, Object value) throws IllegalArgumentExcep
2029
2035
return getKey (key ) + " + " + value ;
2030
2036
}
2031
2037
if (value instanceof String ) {
2032
- return " CONCAT (" + getKey (key ) + ", " + getValue (value ) + ") " ;
2038
+ return SQL . concat ( getKey (key ), ( String ) getValue (value )) ;
2033
2039
}
2034
2040
throw new IllegalArgumentException (key + "+ 对应的值 " + value + " 不是Number,String,Array中的任何一种!" );
2035
2041
}
@@ -2045,7 +2051,7 @@ public String getRemoveString(String key, Object value) throws IllegalArgumentEx
2045
2051
return getKey (key ) + " - " + value ;
2046
2052
}
2047
2053
if (value instanceof String ) {
2048
- return SQL .replace (getKey (key ), (String ) getValue (value ), "" );// " replace(" + key + ", '" + value + "', '') ";
2054
+ return SQL .replace (getKey (key ), (String ) getValue (value ), "'' " );// " replace(" + key + ", '" + value + "', '') ";
2049
2055
}
2050
2056
throw new IllegalArgumentException (key + "- 对应的值 " + value + " 不是Number,String,Array中的任何一种!" );
2051
2057
}
0 commit comments