Passing a RegExp object to $regex inside $elemMatch causes a crash
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 65/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- javascript
- 領域
- database
調査の方向性
Start by running the attached repro-pouchdb-elemmatch.js in the Node.js environment and compare string and RegExp patterns inside $elemMatch. Trace the crash for arrays of objects in the memory and indexedDB backends; done means the reproduced query no longer crashes and the supported regex behavior or compatibility limitation is documented.
索引モデルが issue の本文から書いたものです。
説明
Issue
I came across a quirk/bug in pouchdb yesterday, I'm not sure whether to report it. It relates to the use of $regex inside $elemMatch in a find query. We wanted to have a case insensitive regex and so passed in a Javascript RegExp object asa the pattern. This worked as long as the $elemMatch branch did not trigger - for plain values the expression matches ok. If the value is an array of objects, we get a crash inside pouchdb.
So this could just be that we're over-reaching in our use of $regex by sending a RegExp object. There is no documentation about what kind of value we can pass other than a pointer to the CouchDB docs which then points to the Erlang reference and PCRE. Based on PCRE I could use (?i) to make the pattern case insensitive but this is not accepted by pouchdb - as far as I can see it just passes the pattern internally to RegExp.
The easiest route to being able to support case-insensitive regex would be to fix this regression and document the use of RegExp, however this wouldn't work for the http backend since CouchDB expects PCRE expressions. The alternate would be to support PCRE modifiers in the local backend. Some mention of compatibility in the documentation would also be useful.
Info
- Environment: NodeJS and browser using in-memory and indexedDB backends
- Platform: Node and Chrome tested
- Adapter: memory, indexeddb
- Server: None
Reproduce
The attached script shows a reproduction. It adds documents including one containing an array of one object, then runs the query using both string and RegExp patterns. Comment out the first document in the bulkDocs call to avoid the crash.
- 主要言語
- JavaScript
- スター
- 17.6k
- フォーク
- 1.5k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/pouchdb のほかの issue
-
elemMatch throws TypeError: value is null if array has null element対応中かも @henyanagar が 145 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
-
View indexer advances `_local/lastSeq` past failed batch writes — permanent silent view index corruption再び着手できるかも @janl が 67 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
approved check:passed logos:add
難易度 1/5 1時間未満 初心者へのやさしさ 74/100
メンテナーはふだん 2 日以内に返信
-
binding:python bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
AOSSIE-Org/BabyNest#310 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug needs-triage potential-regression
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
aws/aws-sdk-js-v3#8408 ·
メンテナーはふだん 1 日以内に返信