w***@163.com
w***@163.com
  • 发布:2024-11-16 22:21
  • 更新:2024-11-21 12:05
  • 阅读:80

【报Bug】字符串过长时模糊查询匹配不到结果

分类:uniCloud

产品分类: uniCloud/App

示例代码:

[
{
"_id": "6738846ca674f4d0a393d125",
"add_date": 1731757163864,
"category_id": 2,
"department": "665b321cee97ef58965c557e",
"goods_id": "672f015f189f8669f3a99123",
"goods_name": "而在吗测试",
"last_modify_date": 1731757163864,
"market_price": 0,
"model": "cbe8423dbc2f8d419b1cd90e",
"model_in": "2222222222222222222222222222",
"model_out": "333333333333333333333333333",
"orderStatus": 1
}
]

db.collection('opendb-mall-sku').where(${new RegExp('2', 'i')}.test(model)).get()

操作步骤:

db.collection('opendb-mall-sku').where(${new RegExp('2', 'i')}.test(model)).get()

预期结果:

[
{
"_id": "6738846ca674f4d0a393d125",
"add_date": 1731757163864,
"category_id": 2,
"department": "665b321cee97ef58965c557e",
"goods_id": "672f015f189f8669f3a99123",
"goods_name": "而在吗测试",
"last_modify_date": 1731757163864,
"market_price": 0,
"model": "cbe8423dbc2f8d419b1cd90e",
"model_in": "2222222222222222222222222222",
"model_out": "333333333333333333333333333",
"orderStatus": 1
}
]

实际结果:

[]

bug描述:

以下是表中某行数据
[
{
"_id": "6738846ca674f4d0a393d125",
"add_date": 1731757163864,
"category_id": 2,
"department": "665b321cee97ef58965c557e",
"goods_id": "672f015f189f8669f3a99123",
"goods_name": "而在吗测试",
"last_modify_date": 1731757163864,
"market_price": 0,
"model": "cbe8423dbc2f8d419b1cd90e",
"model_in": "2222222222222222222222222222",
"model_out": "333333333333333333333333333",
"orderStatus": 1
}
]
以下是查询方法
db.collection('opendb-mall-sku').where(${new RegExp('2', 'i')}.test(model)).get()

当model字段字母数字混合长度大于24个时,模糊查询结果为空,小于等于24个,查询正常

2024-11-16 22:21 负责人:无 分享
已邀请:
DCloud_uniCloud_VK

DCloud_uniCloud_VK

你再试下,是否只有刚好24位的不能模糊查询

已知24位会转ObjectId,此时不是字符串,故不能模糊查询

要回复问题请先登录注册