Skip to content

Commit 265480b

Browse files
committed
Server:解决NOT JSON_CONTAINS(NULL, ...)无结果并优化性能
1 parent 9ad7cf7 commit 265480b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

APIJSON-Java-Server/APIJSONLibrary/src/main/java/zuo/biao/apijson/server/AbstractSQLConfig.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,7 @@ public static String getContainString(String key, Object value) throws NotExistE
825825
* @throws IllegalArgumentException
826826
*/
827827
public static String getContainString(String key, Object[] childs, int type) throws IllegalArgumentException {
828+
boolean not = Logic.isNot(type);
828829
String condition = "";
829830
if (childs != null) {
830831
for (int i = 0; i < childs.length; i++) {
@@ -840,13 +841,15 @@ public static String getContainString(String key, Object[] childs, int type) thr
840841
}
841842
}
842843
if (condition.isEmpty()) {
843-
condition = (SQL.isEmpty(key, true) + OR + (key + "='[]'"));
844+
condition = (SQL.isNull(key, true) + OR + getLikeString(key, "[]")); // key = '[]' 无结果!
845+
} else {
846+
condition = (SQL.isNull(key, false) + AND + "(" + condition + ")");
844847
}
845848
}
846849
if (condition.isEmpty()) {
847850
return "";
848851
}
849-
return getCondition(Logic.isNot(type), condition);
852+
return getCondition(not, condition);
850853
}
851854
//<> contain >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
852855

APIJSON-Java-Server/APIJSONLibrary/src/main/java/zuo/biao/apijson/server/AbstractSQLExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public JSONObject execute(SQLConfig config) throws Exception {
124124
long startTime = System.currentTimeMillis();
125125
Log.d(TAG, "\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
126126
+ "\n select startTime = " + startTime
127-
+ "\n sql = " + sql
127+
+ "\n sql = \n " + sql
128128
+ "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
129129

130130
ResultSet rs = null;

0 commit comments

Comments
 (0)