支付宝云JQL语法下在uni-app中使用where内使用in和取反!(xx in [])效果一致
支付宝云JQL语法下在uni-app中使用where内使用in和取反!(xx in [])效果一致
操作步骤:
- 在支付宝云服务空间下测试where条件的
in
和!(xx in [])
预期结果:
- 取反应该把不包含的遍历出来
实际结果:
- 并没有起到取反的结果
bug描述:
let {data:resData} = await dbJQL.collection("JLJ-coupon-list").where(`state == 1 && allow_type=="all" && !(user_group_use in ${JSON.stringify([userInfo.uid])})`).field({price:true,name:true}).get();
return resData
如上所述代码,user_group_use in ${JSON.stringify([userInfo.uid])}
是要查询数据表中user_group_use
数组字段内,是否包含给定当前用户组,包含情况是可以查询出来的。如果使用!(xx in [])
并没有实现取反效果,请大佬检查是否是支付宝云的bug,在阿里云测试是可以的。
更多关于支付宝云JQL语法下在uni-app中使用where内使用in和取反!(xx in [])效果一致的实战教程也可以访问 https://www.itying.com/category-93-b0.html
3 回复
你的hx版本多少呢?
更多关于支付宝云JQL语法下在uni-app中使用where内使用in和取反!(xx in [])效果一致的实战教程也可以访问 https://www.itying.com/category-93-b0.html
最新的版本4.64同样出现这个问题,取反不起作用
根据你的描述,这可能是支付宝云JQL实现的一个兼容性问题。在标准JQL语法中,!(xx in [])
确实应该实现取反效果,与阿里云的行为一致。
从代码来看,你的查询逻辑是正确的。建议可以尝试以下替代方案:
- 使用
not in
操作符替代:
let {data:resData} = await dbJQL.collection("JLJ-coupon-list")
.where(`state == 1 && allow_type=="all" && user_group_use not in ${JSON.stringify([userInfo.uid])}`)
.field({price:true,name:true})
.get();
- 或者使用数组长度判断:
let {data:resData} = await dbJQL.collection("JLJ-coupon-list")
.where(`state == 1 && allow_type=="all" && size(user_group_use[${userInfo.uid}]) == 0`)
.field({price:true,name:true})
.get();