参考资料:APIJSON/Document.md at master · Tencent/APIJSON · GitHub
测试平台:APIAuto-机器学习测试、自动生成代码、自动静态检查、自动生成文档与注释等,做最先进的 HTTP 接口管理平台。 (apijson.cn)
{
"User[]": {
"count": 3,
"User": {}
}
}
结果:通过。
{
"User[]": {
"count": 3,
"User": {
"id{}": [
38710,
82001,
70793
]
}
}
}
结果:通过。
{
"User[]": {
"count": 3,
"User": {
"id{}": "<=80000,>90000"
}
}
}
结果:通过。
{
"User[]": {
"count": 3,
"User": {
"contactIdList<>": 38710
}
}
}
结果:测试未通过;
不正确的sql:
SELECT * FROM "DB2ADMIN"."apijson_user" WHERE ( ("contactIdList" is NOT null AND (json_contains("contactIdList", '38710'))) ) ORDER BY "id" LIMIT 3
json_contains这个函数暂时没找到替代的,可能是db2不支持。
{
"User": {
"id}{@": {
"from": "Comment",
"Comment": {
"momentId": 15
}
}
}
}
结果:通过。
{
"Moment": {
"id": 301,
"isPraised()": "isContain(praiseUserIdList,userId)"
}
}
测试:未通过:
报错信息:不允许调用远程函数 isContain !
{
"User": {
"@limit": 10,
"@offset": 0,
"@procedure()": "getCommentByUserId(id,@limit,@offset)"
}
}
结果:未通过;
报错信息:"[jcc][10111][10815][4.28.11] 不能对预编译语句实例调用 java.sql.PreparedStatement.execute (String sql) 方法。 使用 java.sql.PreparedStatement.execute () 时不附带 SQL 字符串自变量。 ERRORCODE=-4476, SQLSTATE=null"
{
"Moment": {
"userId": 38710
},
"User": {
"id@": "%2FMoment%2FuserId"
}
}
结果:通过
{
"User": {
"id@": {
"from": "Comment",
"Comment": {
"@column": "min(userId)"
}
}
}
}
结果:通过
{
"User[]": {
"count": 3,
"User": {
"name$": "%ap%"
}
}
}
结果:通过
{
"User[]": {
"count": 3,
"User": {
"name~": "^[0-9]%2B$"
}
}
}
结果:测试未通过
错误的sql语句:
SELECT * FROM "DB2ADMIN"."apijson_user" WHERE ( ("name" REGEXP BINARY '^[0-9]%2B$') ) ORDER BY "id" LIMIT 3
正确的sql语句:
SELECT * FROM "DB2ADMIN"."apijson_user" WHERE 'name' LIKE '^[0-9]%2B$' ORDER BY "id" LIMIT 3;
REGEXP BINARY修改为LIKE
{
"User[]": {
"count": 3,
"User": {
"date%": "2017-10-01,2018-10-01"
}
}
}
结果:通过
{
"Comment": {
"@column": "id,toId:parentId",
"id": 51
}
}
结果:通过
{
"[]": {
"User": {
"id<=": 90000
}
}
}
// 用例2
{
"User": {
"id>@": {
"from": "Comment",
"Comment": {
"@column": "min(userId)"
}
}
}
}
结果:通过
{
"User": {
"id&{}": ">80000,<=90000"
}
}
// 样例2
{
"User": {
"id|{}": ">90000,<=80000"
}
}
// 样例
{
"User": {
"id!{}": [
82001,
38710
]
}
}
结果:通过
{
"[]": {
"count": 5,
"User": {}
}
}
结果:通过
{
"[]": {
"count": 5,
"page": 3,
"User": {}
}
}
结果:通过
{
"[]": {
"query": 2,
"count": 5,
"User": {}
},
"total@": "%2F[]%2Ftotal",
"info@": "%2F[]%2Finfo"
}
结果:通过
{
"[]": {
"count": 5,
"join": "&/User/id@,</Comment/momentId@",
"Moment": {
"@column": "id,userId,content"
},
"User": {
"name~": "t",
"id@": "/Moment/userId",
"@column": "id,name,head"
},
"Comment": {
"momentId@": "/Moment/id",
"@column": "id,momentId,content"
}
}
}
结果:未通过
错误的sql
SELECT "Moment"."id","Moment"."userId","Moment"."content", "User"."id","User"."name","User"."head", "Comment"."id","Comment"."momentId","Comment"."content" FROM "DB2ADMIN"."Moment" AS "Moment"
INNER JOIN "DB2ADMIN"."apijson_user" AS "User" ON "User"."id" = "Moment"."userId"
LEFT JOIN ( SELECT "id","momentId","content" FROM "DB2ADMIN"."Comment" ) AS "Comment" ON "Comment"."momentId" = "Moment"."id" WHERE ( ( ( ("User"."name" REGEXP BINARY 't') ) ) ) ORDER BY "Moment"."id" LIMIT 5
正确sql:
SELECT "Moment"."id","Moment"."userId","Moment"."content", "User"."id","User"."name","User"."head", "Comment"."id","Comment"."momentId","Comment"."content" FROM "DB2ADMIN"."Moment" AS "Moment"
INNER JOIN "DB2ADMIN"."apijson_user" AS "User" ON "User"."id" = "Moment"."userId"
LEFT JOIN ( SELECT "id","momentId","content" FROM "DB2ADMIN"."Comment" ) AS "Comment" ON "Comment"."momentId" = "Moment"."id" WHERE ( ( ( ("User"."name" LIKE 't') ) ) ) ORDER BY "Moment"."id" LIMIT 5
本质错误:REGEXP BINARY 修改为 LIKE
{
"User": {},
"[]": {
"name@": "User/name",
"Moment": {}
}
}
结果:通过
(待完善)