MongoDB extended operator rules erroneously applied to SQL databases and json bodies
まだ誰も着手していません。
評価
- 難易度
- 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時間
- マージ済み PR(30日)
- 9
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
loopbackio/loopback-connector-postgresql のほかの issue
-
Partial JSON Update対応中かも @vaibhavbhalla2505 が 264 日前に担当しました。 オープンfeature
難易度 5/5 1週間以上 初心者へのやさしさ 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
-
難易度 2/5 1〜3時間 初心者へのやさしさ 71/100
yjh051108/dsh-routing-suite#227 ·
-
needs-triage release-watch
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
dusk-network/exu#17 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
jspreadsheet/ce#1809 ·
-
documentation
難易度 1/5 1時間未満 初心者へのやさしさ 91/100
githubnext/gh-aw-workshop#4458 ·
メンテナーはふだん 1 日以内に返信