|
56 | 56 | import apijson.StringUtil; |
57 | 57 | import apijson.orm.AbstractSQLConfig.IdCallback; |
58 | 58 | import apijson.orm.exception.ConflictException; |
| 59 | +import apijson.orm.exception.NotExistException; |
59 | 60 | import apijson.orm.exception.NotLoggedInException; |
60 | 61 | import apijson.orm.model.Access; |
61 | 62 | import apijson.orm.model.Column; |
@@ -610,7 +611,25 @@ private static void verifyId(@NotNull String method, @NotNull String name, @NotN |
610 | 611 | //new ArrayList<Long>(idIn) 不能检查类型,Java泛型擦除问题,居然能把 ["a"] 赋值进去还不报错 |
611 | 612 | for (int i = 0; i < idIn.size(); i++) { |
612 | 613 | Object o = idIn.get(i); |
613 | | - if (o != null && o instanceof Number == false && o instanceof String == false) { |
| 614 | + if (o == null) { |
| 615 | + throw new IllegalArgumentException(method + "请求," + name + "/" + key |
| 616 | + + " 里面的 " + idInKey + ":[] 中所有项都不能为 [ null, <= 0 的数字, 空字符串 \"\" ] 中任何一个 !"); |
| 617 | + } |
| 618 | + if (o instanceof Number) { |
| 619 | + //解决 Windows mysql-5.6.26-winx64 等低于 5.7 的 MySQL 可能 id{}: [0] 生成 id IN(0) 触发 MySQL bug 导致忽略 IN 条件 |
| 620 | + //例如 UPDATE `apijson`.`TestRecord` SET `testAccountId` = -1 WHERE ( (`id` IN (0)) AND (`userId`= 82001) ) |
| 621 | + if (((Number) o).longValue() <= 0) { |
| 622 | + throw new IllegalArgumentException(method + "请求," + name + "/" + key |
| 623 | + + " 里面的 " + idInKey + ":[] 中所有项都不能为 [ null, <= 0 的数字, 空字符串 \"\" ] 中任何一个 !"); |
| 624 | + } |
| 625 | + } |
| 626 | + else if (o instanceof String) { |
| 627 | + if (StringUtil.isEmpty(o, true)) { |
| 628 | + throw new IllegalArgumentException(method + "请求," + name + "/" + key |
| 629 | + + " 里面的 " + idInKey + ":[] 中所有项都不能为 [ null, <= 0 的数字, 空字符串 \"\" ] 中任何一个 !"); |
| 630 | + } |
| 631 | + } |
| 632 | + else { |
614 | 633 | throw new IllegalArgumentException(method + "请求," + name + "/" + key |
615 | 634 | + " 里面的 " + idInKey + ":[] 中所有项的类型都只能是 Long 或 String !"); |
616 | 635 | } |
|
0 commit comments