y***@163.com
y***@163.com
  • 发布:2022-08-23 10:48
  • 更新:2022-08-25 15:56
  • 阅读:381

【报Bug】当schema中指定了超过2个parentKey时,getTree查询数据库时虽然指定了parentKey, 系统报错

分类:uniCloud

产品分类: uniCloud/App

示例代码:

test.schema.json
···
{
"bsonType": "object",
"required": [],
"permission": {
"read": false,
"create": false,
"update": false,
"delete": false
},
"properties": {
"_id": {
"description": "ID,系统自动生成"
},
"name":{
"bsonType": "string",
"title": "姓名",
"trim": "both",
"minLength": 2
},
"parent_id":{
"bsonType": "string",
"title": "父id",
"parentKey": "_id"
},
"mother_id":{
"bsonType": "string",
"title": "母id",
"parentKey": "_id"
},
"teacher_id":{
"bsonType": "string",
"title": "师傅id",
"parentKey": "_id"
}
}
}
···

查询代码:

db.collection("test")  
    .parentKey("parent_id")  
    .get({getTree: {  
        startWith:"/张三/i.test('name')"  
        }  
    })

操作步骤:

1、在项目的 uniCloud/database 目录下建立文件 test.schema.json (代码见上面的代码示例)
2、上传 test.schema.json
3、在 uniCloud/database 目录下的 JQL查询.jql 文件中输入查询代码(见上面的代码示例)
4、执行JQL查询语句

预期结果:

···
{
"result": {
"affectedDocs": 0,
"code": 0,
"data": [
],
"errCode": 0,
"errMsg": "",
"message": "",
"systemInfo": [
],
"timeCost": 910
}
}
···

实际结果:

出现错误提示:
schema内存在多个parentKey,请使用parentKey方法指定要使用的parentKey

bug描述:

当schema中指定了超过2个parentKey时,getTree查询数据库时虽然指定了parentKey, 系统会报错:
schema内存在多个parentKey,请使用parentKey方法指定要使用的parentKey
当schema中指定的parentKey不超过2个时,指定parentKey进行查询,则可以得到正常结果。

2022-08-23 10:48 负责人:无 分享
已邀请:
DCloud_uniCloud_WYQ

DCloud_uniCloud_WYQ

此问题已在HBuilderX 3.5.5修复

要回复问题请先登录注册