Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Bug] Demo项目多表插入报错 #512

Closed
aldag opened this issue Feb 16, 2023 · 7 comments
Closed

[Bug] Demo项目多表插入报错 #512

aldag opened this issue Feb 16, 2023 · 7 comments
Labels

Comments

@aldag
Copy link

aldag commented Feb 16, 2023

APIJSON Version/APIJSON 版本号

6.0.0

Database Type & Version/数据库类型及版本号

mysql 5.7.38

Environment/环境信息

- JDK/基础库: 1.8.0_202
- OS/系统: win10

APIAuto Screenshots/APIAuto 请求与结果完整截屏

Current Behavior/问题描述

6.0.0版APIJSON-Demo项目多表插入报错,如截图中的register用例。
APIJSON-Demo项目除数据库连接外,未做其他代码修改;数据库中的Request表等关键表未做修改。

Expected Behavior/期望结果

No response

Any additional comments?/其它补充说明?

No response

@TommyLemon
Copy link
Collaborator

是个 bug,我这边复现了,改用 5.4.0 以下试试
https://github.com/APIJSON/APIJSON-Demo/releases

@cloudAndMonkey
Copy link
Contributor

cloudAndMonkey commented Feb 17, 2023

@aldag
可以使用APIJSON全能接口 crud, 校验调用远程函数(前置远程函数,可以改变 request 参数), 能实现一样的效果

crud:
相同数据源,不同语句 支持事物
支持apijson校验

{
    "@post": {
        "User:aa": {
            "@datasource": "db2"
        },
        "User_address[]": {
            "@datasource": "db2"
        }
    },
    "User:aa": {
        "username": "test-3",
        "password": "233223",
        "state": 1
    },
    "ES_blog:a": {
        "@datasource": "elasticSearch",
        "title.keyword": "test-2"
    },
    "User_address[]": [
        {
            "user_id@": "User:aa/id",
            "addr": "ddd",
            "count@": "ES_blog:a/count"
        },
        {
            "user_id@": "User:aa/id",
            "addr": "ddd1",
            "count@": "ES_blog:a/count"
        }
    ],
    "@explain": true,
    "format": true
}

@TommyLemon
Copy link
Collaborator

版本6.0.0的APIJSON 您好:这种格式的请求现在不适配了吗 123123123 2222222 我看每个子json都是单独解析的 333331

这里不应该只 requestItem.put(_key, obj),丢了 "Request":{} 对象导致 objectVerify 抛异常,
应该把原始请求的所有键值对 put 进去,可以 requestItem.putAll(原来的 request 对象)。

可以改下源码试试,如果可以麻烦提 PR 贡献下代码哦,开源要大家一起参与贡献才会更美好~
https://github.com/Tencent/APIJSON/blob/master/CONTRIBUTING.md

image

@wahowaho
Copy link
Contributor

试了一下联合插入
6666
您那边看看这么改可以不。

@cloudAndMonkey
Copy link
Contributor

cloudAndMonkey commented Apr 13, 2023

@wahowaho
你好, pr已经看到, 感谢贡献
vertify 方法需要兼容 crud全能接口和 post等method.
按照@TommyLemon 的意思, 别名不做提前 解析, 通过 Request structure 配置解决
#468 (comment)
删除 tag 、JSONObject 别名判断的代码, 或者把crud 和其他 method区别处理, 我晚上测一下, parse里面 会将crud转换为 PUT、DELETE、POST等方法执行, 需要确认是否有影响

@wahowaho
Copy link
Contributor

@cloudAndMonkey 好滴好滴 ^_^

@TommyLemon
Copy link
Collaborator

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants