Skip to content

[bug] PUT "key<>":[] 居然转成了 key = '[]' #276

Closed

Description

@TommyLemon

应该当成条件来处理 或者 直接返回错误信息。

环境信息

  • 系统: Linux CentOS
  • JDK: 1.8.0_17
  • 数据库: MySQL 5.7.14
  • APIJSON: 4.7.0

问题描述

wecom-temp-f0e2ba60360fce7289b97ee1e727352d

http://apijson.cn:8080/put
{
"Moment": {
"id": 15,
"praiseUserIdList<>": [
1
]
},
"tag": "Moment",
"@Explain": true
}

错误信息

无

目前可以通过加 @combine 来解决。
image
{
"Moment": {
"id": 15,
"content": "test",
"praiseUserIdList<>": [
82002
],
"@combine": "praiseUserIdList<>"
},
"tag": "Moment",
"@Explain": true
}

但最好还是在 AbstractObjectParser 中对 key 判断是否为不包含任何符合的 字段名。
image

else if (method == PUT && value instanceof JSONArray && (whereList == null || whereList.contains(key) == false))

改为

else if (method == PUT && value instanceof JSONArray && (whereList == null || whereList.contains(key) == false) && StringUtil.isName(key))

https://github.com/Tencent/APIJSON/blob/0e06d1989a7a23de7115df5c9ab0a8166dd720ee/APIJSONORM/src/main/java/apijson/orm/AbstractObjectParser.java

类似问题: "userId>": 82002 转为了 userId = 82002
image

image

image

不能这么简单地判断 isWhere,而是在循环内判断 method != PUT || (StringUtil.isName(key) == false)

https://github.com/Tencent/APIJSON/blob/0e06d1989a7a23de7115df5c9ab0a8166dd720ee/APIJSONORM/src/main/java/apijson/orm/AbstractSQLConfig.java

Activity

  1. TommyLemon commented on Dec 2, 2021

    @TommyLemon
    MemberAuthor

    感谢 @chenyanlann 修复了这个 bug 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions