Passing a RegExp object to $regex inside $elemMatch causes a crash
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 65/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- javascript
- Ambito
- database
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- JavaScript
- Stelle
- 17.6k
- Fork
- 1.5k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/pouchdb
-
elemMatch throws TypeError: value is null if array has null elementForse già presa @henyanagar l’ha presa 143 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Validate database namesAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 22/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
-
View indexer advances `_local/lastSeq` past failed batch writes — permanent silent view index corruptionForse di nuovo libera @janl l’ha presa 65 giorni fa e non c’è nessuna pull request aperta. Aperta
apache/pouchdb#9265 · 1 commento · 4 reazioni · 1 assegnatario ·
Tutte le issue di apache/pouchdb
Issue simili
-
curriculum documentation quality
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
githubnext/gh-aw-workshop#5367 ·
I maintainer di solito rispondono entro 3 giorni
-
Add: Animal Planet BGApertachannels:add check:passed
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
I maintainer di solito rispondono entro 4 giorni
-
beginner blocked
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
hiero-ledger/hiero-sdk-js#4670 ·
I maintainer di solito rispondono entro 1 giorno
-
Media widget: selecting a paused player is ignored while another paused player holds an audio streamAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
area: editor complexity: easy impact: low status: triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
ueberdosis/tiptap#8699 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno