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
Handle undefined value in an object #663
Comments
I feel like ignoring |
I agree with @jdoliner -- I think the JS driver should error when |
Hum, I don't think throwing an error is a absolutely bad, but in CoffeeScript, this syntax is legal
It get parsed to
Which will throw an error if we directly pass it to |
If |
So the easiest way to delete An attribute is with replace and without. For table.replace(lambda row: row.without("foo"))
|
To clarify, |
Here's what's actually happening here. The driver attempts to convert any native values passed to it into a RQL datum. Since it doesn't know how to convert 1 this error is sufficient, do nothing We already do something like option 2 in the case of a lambda function returning undefined. We could add other common cases to help people understand where the error is coming from (in this case because that property isn't set on the original object. This change would actually require more work than the other two options but helps people uncover situations that are mostly likely errors as in this case. Michel's right that the last option is must more javascript-y. Fields whose value is I'm not actually sure where my personal opinion falls on this. I do agree that the place to handle this situation is probably not within the datum constructor where we've lost all context for the error. |
I feel like this could be confusing. If I saw a query We could change the protobuf to actually support I'd prefer fixing the actual problem at hand. Why don't we add a better error message for this specific issue (people passing TL;DR: less is more. |
What might be better is to add |
This is almost certainly better from the user's POV, but requires more work on the server (which already has quite a backlog). @mlucy -- how much work do you think this is? (I think I'd prefer adding a better error message here in the JS driver in the short term, and adding |
So I don't fully understand what it would mean for |
I have two proposals. Adding a I'm imagining that much like You might consider this too hacky if it has to be handled as a special value at the DatumTerm level, but it would fit with javascript conventions. Also I'm just guessing that |
@taybin is As a value As an operation, I'm having trouble seeing how Personally, I agree with @coffeemug that the right way to close this issue is to provide a better error message when an |
I was thinking it would be an operation. Having a third type of non-existence clearly isn't the way to go. I was speculating that |
It might not necessarily be different, but it certainly would offer a degree of convenience that Anyway, let's go with a better error message for now. We'll open a separate issue for |
Assigning to @wmrowan via 1.5-sprint-3. |
in code review 427 by @coffeemug |
@wmrowan -- what's the state of this issue? (the review has been cancelled) |
This was in the big review and part of the package that just got merged. I must not have split out the commit that contained this fix into a separate review. This is the relevant commit: e553169 |
Could you submit a code review with the relevant polyglot tests? |
review number 452 |
I am trying to remove a value from a document. I am really, really surprised I can't simply call The error is: |
If you want to remove a fielld, you should use
If we were using undefined to remove a field, it would mean
would erase all other fields since they are all undefined. |
|
So, we could make the JS driver treat This might be worth revisiting though, if a lot of people report running into this problem. |
I would like this behavior, but first #4428 should be fixed |
@neumino From the above discussion there is no clear conclusion as to how
This will throw error
Logically since I have a users table where What I would like is for this query to not throw error and return I have been reading the docs and is not able to find the solution. How to get this done in rethink world.
This will return all the users and completely ignore Additional Info
|
`ryexley on IRC had trouble replicating our nodejs chat application.
He got this error
While this error make a lot of sense when the user forget a return in a lamda function for a filter for example, here it was failing for this query:
And the reason why, was because one of the field had the value
undefined
.We should catch undefined values in
r.expr()
and just ignore the key if undefined is returned.Assigning to @wmrowan, tagging as 1.5
The text was updated successfully, but these errors were encountered: