You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Nested pluck syntax throws when it shouldn't #1095
Actually, sorry, it shouldn't drop the row (since in other cases pluck never reduces the size of the stream). I'm not sure what it should return in this case, actually. @mlucy -- can you comment?
So unfortunately this example data is small enough that these proposals don't actually fully explain the syntax. Let's just have the rule that if a pluck attempts to pluck from a field with key a and the value of field a is not a pluckable type then we treat it as if there is no field with key a.
Also just to be clear because we actually weren't on the same page when we discussed before but thought we were.
r.expr([1,2,3,4]).pluck("foo")
Should throw. I feel like if you're trying to pluck directly on a non object then most likely you've just made a typo. and converting numbers to empty objects seems awfully odd.
Activity
coffeemug commentedon Jun 29, 2013
Actually, sorry, it shouldn't drop the row (since in other cases pluck never reduces the size of the stream). I'm not sure what it should return in this case, actually. @mlucy -- can you comment?
coffeemug commentedon Jun 29, 2013
And by "I'm not sure what it should return", I mean that I'm not sure if it should return
{a: {}}for the document in question or{}.coffeemug commentedon Jun 29, 2013
Also: sorry for spamming, but I'm playing with the syntax and it's pretty freakin' sweet.
mlucy commentedon Jun 29, 2013
I think it should return
[{:a => {:c => 1}}, {}].jdoliner commentedon Jun 29, 2013
So unfortunately this example data is small enough that these proposals don't actually fully explain the syntax. Let's just have the rule that if a pluck attempts to pluck from a field with key
aand the value of fieldais not a pluckable type then we treat it as if there is no field with keya.jdoliner commentedon Jun 29, 2013
Also @mlucy I don't understand your proposal, why do you drop a row?
jdoliner commentedon Jun 29, 2013
Speaking in terms of examples:
I think this is probably the most useful behavior. Also I feel pretty strongly that:
should still throw.
mlucy commentedon Jun 29, 2013
@jdoliner -- I think the behavior you want is right.
jdoliner commentedon Jun 29, 2013
Also just to be clear because we actually weren't on the same page when we discussed before but thought we were.
Should throw. I feel like if you're trying to pluck directly on a non object then most likely you've just made a typo. and converting numbers to empty objects seems awfully odd.
coffeemug commentedon Jun 29, 2013
@jdoliner -- the behavior you're describing seems right to me as well.
jdoliner commentedon Jul 1, 2013
This is fixed and in next as of f32acd4. CR 685 by @mlucy.