-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Uncaught error while using DOT '.' notation on undefined field #5030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I guess it as simple as adding a if before this line Line 418 in a421015
(and this one Line 481 in a421015
But I'm not sure how to break it down 🤔 Or just encapsulate it into a try/catch block. Is that compliant to the good-practices of this repo ? |
Please open a pull request. Using a try catch won’t help as it won’t provide any additional informations |
Similar to #4740 , which is the same issue but for |
I'll have to read up on how to submit a PR later. I found this SO post helpful.
This essentially implements I moved it out of the values.push() so that we could only call that conditionally on a value actually existing, as at least in my browser 'undefined' actually gets added to the array. That being said, if there was no value before 'undefined' would still get added to the array, and didn't seem to cause any problems. I suppose this could be changed to, which would maintain that "legacy" functionality. But I took it as more of an oversight, since the array would then have as many values as the array of results from the first query, even if only a single object with the relevant field we're looking for existed.
That would replace both of the lines @seza443 pointed out. Relevant references: Also, I have a test case in #4740, regarding this same issue I can move over. |
@JacobJT would you be willing to write a failing test? |
Issue Description
When building a query with a
matchesKeyInQuery
operator with a DOT notation (made available in #4399 thanks for that), an uncaught error occurs if the first part of the DOT notation is undefined.Steps to reproduce
SubClass has a Pointer parent to ParentClass but sometimes, it is undefined.
Expected Results
I expect to see the results matching the filters and ignoring the fields that are undefined
Actual Outcome
I receive an Undefined error
Server logs:
Environment Setup
Server
Database
Logs/Trace
The text was updated successfully, but these errors were encountered: