MongoDB extended operator rules erroneously applied to SQL databases and json bodies
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript, postgresql
- 领域
- database
调研方向
从 loopback-datasource-juggler 的 pull request 1662 引入的验证代码开始,并通过对包含顶层 $ 键的 PostgreSQL JSON 字段执行 find() 调用来重现该问题。完成的标准是 SQL JSON 相等查询不再引发 OPERATOR_NOT_ALLOWED_IN_QUERY,同时 MongoDB 扩展操作符验证仍然适用。
由索引模型根据 Issue 内容生成。
描述
NOTE: This is a bug in loopback-datasource-juggler, however the issue template there explicitly requests filing bugs in this project so 🤷
https://github.com/loopbackio/loopback-datasource-juggler/pull/1662 brought in some validation code that only is applicable to MongoDB, and is making certain operation on JSON properties/columns with SQL databases excessively difficult.
It is already impossible to do json equality searches out of the box due to #477, however that issue has a fairly straight forward workaround.
That workaround fails if the JSON object you are searching for contains any properties starting with a $ at the top level however, because they are interpreted as extended operators, even if they cannot possibly actually be such.
For example, pretend #477 was already fixed and you wrote this where expression:
{ where: { propertyName: { eq: { $foo: 'bar' } } } }
The $foo, AFAICT, cannot possibly be an operator because you already specified the eq operator.
Furthermore, if you're not using MongoDB, then this whole thing is moot anyways and these checks are inapplicable.
Steps to reproduce
- Create an entity type with a property of object type mapped to a SQL field of json type
- Insert a record that has a key in this property, at the top level, whose name starts with a
$ - Attempt to do a
find()call to locate this record using an equality match on that property
Current Behavior
- #477 gets in your way
- Even with the workaround for that, Loopback throws a
OPERATOR_NOT_ALLOWED_IN_QUERYerror and refuses to run your query
Expected Behavior
Loopback should be able to do property = ? queries on JSON fields against SQL databases.
Link to reproduction sandbox
WIP
Additional information
Same environment as #477
Related Issues
- #477
- 主要语言
- JavaScript
- 星标
- 118
- 派生
- 183
- 平均合并
- 3 天 7 小时
- 30 天内合并 PR
- 9
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
loopbackio/loopback-connector-postgresql 的其他 Issue
-
Partial JSON Update可能已有人在做 @vaibhavbhalla2505 于 266 天前认领。 未关闭feature
难度 5/5 一周以上 新手友好度 20/100
-
bug
难度 4/5 3-5 天 新手友好度 30/100
loopbackio/loopback-connector-postgresql#748 · 1 条评论 ·
-
bug
难度 3/5 1-2 天 新手友好度 38/100
-
bug
难度 4/5 3-5 天 新手友好度 25/100
-
bug
难度 2/5 1-3 小时 新手友好度 45/100
loopbackio/loopback-connector-postgresql#732 · 1 条评论 ·
查看 loopbackio/loopback-connector-postgresql 的全部 Issue
相似的 Issue
-
ACK_WAITING HELP_WANTED UPDATE_CS
难度 2/5 1-3 小时 新手友好度 78/100
OWASP/CheatSheetSeries#2781 ·
维护者通常 1 天内回复
-
Hermes: /ponytail off never reaches the model, the ruleset stays active可能已有人在做 @szsunyuan 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
DietrichGebert/ponytail#1121 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
integrations plugin
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
bug package:vitest
难度 2/5 1-3 小时 新手友好度 83/100
cloudflare/workers-sdk#16238 · 1 条评论 ·
维护者通常 1 天内回复