-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Should .pluck error behavior be like .without's? #43
Comments
I'd say without should error here. My feeling is that we should error by default and offer people a way to have it not error if it's not found. Maybe we'd also want a way to have a default value for the plucks. I prefer this because compensating for missing parameters winds up being a big pain since it comes up in so many places and I don't think it's good to make people learn different rules for each case. Better to just consistently error if a parameter is missing and give people ways to have default values. |
Hi - I am woogley from IRC. To quickly illustrate my point:
Now, a vanilla run() will return:
(The Star Trek entry simply lacks the However, if you pluck:
It throws this error:
So I would say the inconsistency has less to do with I would expect the |
I think the behavior is correct as is. The server always behaves consistently -- if the query tries to evaluate an attribute and the attribute doesn't exist, it throws an error. If the query doesn't need to evaluate the attribute, the server proceeds as planned. In case of As far as making dealing with these errors easier on the user, I agree with @jdoliner -- we'll address it via #27. |
So the way to do this right now is as follows:
Not pretty but it will let you run the query and have nulls filled in for the other values. Having defaults is in essence sugar for this command. |
Added an issue to make it more pleasant, see #45. |
According to IRC user woogley,
pluck(x, y, z)
will error on rows lacking one of such keys x, y, or z. However,without(x, y, z)
will not error if a row lacks such a key. In general it can be useful to trim down JSON documents to save on network traffic if you're only going to look at a subset of fields, even if some are lacking. Is erroring on rows that lack such fields the behavior we want?The text was updated successfully, but these errors were encountered: