Passing a RegExp object to $regex inside $elemMatch causes a crash
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 65/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript
- Lĩnh vực
- database
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- JavaScript
- Star
- 17.6k
- Fork
- 1.5k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/pouchdb
-
elemMatch throws TypeError: value is null if array has null elementCó thể đã có người làm @henyanagar đã nhận 147 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
unref event is not documentedĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Validate database namesĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
-
View indexer advances `_local/lastSeq` past failed batch writes — permanent silent view index corruptionCó thể làm lại được @janl đã nhận 69 ngày trước và không có pull request nào đang mở. Đang mở
apache/pouchdb#9265 · 1 bình luận · 4 reaction · 1 người được giao ·
Tất cả issue của apache/pouchdb
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ImranR98/apps.obtainium.imranr.dev#2000 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
routing: the tray panel's stage stands still with motion reduced while a request is in flightĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
microsoft/monaco-editor#5577 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
obsidianmd/obsidian-help#1169 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[docs] RELEASE.md: wrong branch name, no check that the prepare PR merged with the right subject, manual publish stepCó thể đã có người làm @albertteoh đã nhận hôm nay. Đang mởdocumentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
jaegertracing/jaeger-ui#4739 ·
Maintainer thường phản hồi trong vòng 1 ngày