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
Better feedback in case of error for orderBy() #118
The query fails which is expected because [1. 3, 2] is not a sequence.
r.expr([1,3,2]).orderBy(r('@')).run()
But the response is not really user friendly
{
"name":"Broken Client",
"message":"Client is buggy (failed to deserialize protobuf)."
}
There is also a warning in the terminal where rethink has been started.
libprotobuf ERROR google/protobuf/message_lite.cc:123] Can't parse message of type "Query" because it is missing required fields: read_query.term.call.builtin.order_by[0].attr
I think that orderby can only take a list of ascending or descending attributes, not an arbitrary expression. It looks like the problem here is that the javascript client is generating an invalid protobuf since r('@') isn't an attribute. (I'm guessing, of course.)
Hopefully the new protobuf spec will be less susceptible to this sort of mistake.
We actually have a similar problem in a lot of places. We have sugar for letting people specify basically pass a function which is just selecting an attribute but we do it inconsistently. It would be nice if it was unified.
To be fair, groupby isn't just sugar for sort, because groupby can use indexes while sort, presumably, will not be able to (or at least I don't see how to easily make it).
I thought we'd agreed to eventually having orderBy and sort where orderBy takes an attribute on which we have an index and sort takes a comparison function. The waters were muddied when we decided for some reason to make orderby polymorphic and its implementation based on a sort of the sequence, destroying the distinction and eliminating the performance gains that were to be had with orderBy.
Can we perhaps add a new issue to post_protobuf_improvements that adds a sort builtin and restores this distinction?
Activity
mlucy commentedon Nov 28, 2012
I think that orderby can only take a list of ascending or descending attributes, not an arbitrary expression. It looks like the problem here is that the javascript client is generating an invalid protobuf since
r('@')isn't an attribute. (I'm guessing, of course.)Hopefully the new protobuf spec will be less susceptible to this sort of mistake.
wmrowan commentedon Nov 28, 2012
@mlucy is right. This is an invalid query. The driver side typechecker should reject this argument as invalid.
jdoliner commentedon Nov 28, 2012
As a side note it would be really cool if we had a version of orderBy that did accept arbitrary lambdas.
coffeemug commentedon Nov 28, 2012
Yeah, we basically want
sort.jdoliner commentedon Nov 28, 2012
We actually have a similar problem in a lot of places. We have sugar for letting people specify basically pass a function which is just selecting an attribute but we do it inconsistently. It would be nice if it was unified.
coffeemug commentedon Nov 29, 2012
To be fair,
groupbyisn't just sugar forsort, becausegroupbycan use indexes while sort, presumably, will not be able to (or at least I don't see how to easily make it).wmrowan commentedon Nov 29, 2012
I thought we'd agreed to eventually having orderBy and sort where orderBy takes an attribute on which we have an index and sort takes a comparison function. The waters were muddied when we decided for some reason to make orderby polymorphic and its implementation based on a sort of the sequence, destroying the distinction and eliminating the performance gains that were to be had with orderBy.
Can we perhaps add a new issue to post_protobuf_improvements that adds a sort builtin and restores this distinction?
chore(board): tick rethinkdb#118 — RT-GAP-004 COMPLETE (b79117a, READ…