Description
What is the current behavior?
If a query string has a collection and subcollection but not a docId it's an invalid query. No error is getting thrown.
What is the expected behavior?
In the queryStrToObj
function, if there is a collection and subcollection, there must always be a doc. I assume an error would be thrown just like in the getQueryConfig
function below it.
redux-firestore/src/utils/query.js
Lines 436 to 438 in a0bab1f
Which version of redux-firestore are you using? What about other dependencies?
v0.12.0
Which environments/browsers are affected by this issue? Did this work in previous versions or setups?
all
Minimal demo to reproduce issue (using codesandbox or similar)
let docId = ''
getQueryConfigs(`/test/${docId}/col/subId`); // returns object with missing doc param {collection:'test', subcollection:[{collection:'col', doc:'subId'}]'
// or
useFirestoreConnect({collection:`/test/${docId}/col/subId`})
I would assume there to be a check in the queryStrToObj
and a corresponding unit test to validate.
redux-firestore/src/utils/query.js
Lines 406 to 416 in a0bab1f
A check could be something like:
if (collection && subcollection && doc === nil) {
throw new Error(
'Invalid Path Definition: Parent document path is empty.',
)
}
Activity