@@ -1284,11 +1284,11 @@ public String getLimitString() {
12841284 public static String getLimitString (int page , int count , boolean isTSQL ) {
12851285 int offset = getOffset (page , count );
12861286
1287- if (isTSQL ) {
1287+ if (isTSQL ) { // OFFSET FECTH 中所有关键词都不可省略
12881288 return " OFFSET " + offset + " ROWS FETCH FIRST " + count + " ROWS ONLY" ;
12891289 }
12901290
1291- return " LIMIT " + count + " OFFSET " + offset ;
1291+ return " LIMIT " + count + ( offset <= 0 ? "" : " OFFSET " + offset ); // DELETE, UPDATE 不支持 OFFSET
12921292 }
12931293
12941294 //WHERE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
@@ -2179,20 +2179,23 @@ public String getContainString(String key, Object[] childs, int type) throws Ill
21792179 String condition = "" ;
21802180 if (childs != null ) {
21812181 for (int i = 0 ; i < childs .length ; i ++) {
2182- if (childs [i ] != null ) {
2183- if (childs [i ] instanceof JSON ) {
2182+ Object c = childs [i ];
2183+ if (c != null ) {
2184+ if (c instanceof JSON ) {
21842185 throw new IllegalArgumentException (key + "<>:value 中value类型不能为JSON!" );
21852186 }
21862187
21872188 condition += (i <= 0 ? "" : (Logic .isAnd (type ) ? AND : OR ));
21882189 if (isPostgreSQL ()) {
2189- condition += (getKey (key ) + " @> " + getValue (newJSONArray (childs [ i ] ))); //operator does not exist: jsonb @> character varying "[" + childs[i] + "]");
2190+ condition += (getKey (key ) + " @> " + getValue (newJSONArray (c ))); //operator does not exist: jsonb @> character varying "[" + c + "]");
21902191 }
21912192 else if (isOracle ()) {
2192- condition += ("json_textcontains(" + getKey (key ) + ", '$', " + getValue (childs [ i ] .toString ()) + ")" );
2193+ condition += ("json_textcontains(" + getKey (key ) + ", '$', " + getValue (c .toString ()) + ")" );
21932194 }
21942195 else {
2195- condition += ("json_contains(" + getKey (key ) + ", " + getValue (childs [i ].toString ()) + ")" );
2196+ boolean isNum = c instanceof Number ;
2197+ String v = (isNum ? "" : "\" " ) + childs [i ] + (isNum ? "" : "\" " );
2198+ condition += ("json_contains(" + getKey (key ) + ", " + getValue (v ) + ")" );
21962199 }
21972200 }
21982201 }
@@ -2390,9 +2393,9 @@ public static String getSQL(AbstractSQLConfig config) throws Exception {
23902393 case POST :
23912394 return "INSERT INTO " + tablePath + config .getColumnString () + " VALUES" + config .getValuesString ();
23922395 case PUT :
2393- return "UPDATE " + tablePath + config .getSetString () + config .getWhereString (true );
2396+ return "UPDATE " + tablePath + config .getSetString () + config .getWhereString (true ) + config . getLimitString () ;
23942397 case DELETE :
2395- return "DELETE FROM " + tablePath + config .getWhereString (true );
2398+ return "DELETE FROM " + tablePath + config .getWhereString (true ) + config . getLimitString () ;
23962399 default :
23972400 String explain = (config .isExplain () ? (config .isSQLServer () || config .isOracle () ? "SET STATISTICS PROFILE ON " : "EXPLAIN " ) : "" );
23982401 if (config .isTest () && RequestMethod .isGetMethod (config .getMethod (), true )) {
@@ -2635,6 +2638,10 @@ public static SQLConfig newSQLConfig(RequestMethod method, String table, String
26352638 throw new NotExistException (TAG + ": newSQLConfig idIn instanceof List >> 去掉无效 id 后 newIdIn.isEmpty()" );
26362639 }
26372640 idIn = newIdIn ;
2641+
2642+ if (method == DELETE || method == PUT ) {
2643+ config .setCount (newIdIn .size ());
2644+ }
26382645 }
26392646
26402647 //对id和id{}处理,这两个一定会作为条件
@@ -2670,6 +2677,10 @@ else if (id instanceof Subquery) {}
26702677 throw new NotExistException (TAG + ": newSQLConfig idIn != null && (((List<?>) idIn).contains(id) == false" );
26712678 }
26722679 }
2680+
2681+ if (method == DELETE || method == PUT ) {
2682+ config .setCount (1 );
2683+ }
26732684 }
26742685
26752686
0 commit comments