Skip to content

Better feedback in case of error for orderBy() #118

Closed

Description

@neumino

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

Activity

  1. mlucy commented on Nov 28, 2012

    @mlucy
    Member

    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.

  2. ghost assigned on Nov 28, 2012
  3. wmrowan commented on Nov 28, 2012

    @wmrowan
    Contributor

    @mlucy is right. This is an invalid query. The driver side typechecker should reject this argument as invalid.

  4. jdoliner commented on Nov 28, 2012

    @jdoliner
    Contributor

    As a side note it would be really cool if we had a version of orderBy that did accept arbitrary lambdas.

  5. coffeemug commented on Nov 28, 2012

    @coffeemug
    Contributor

    Yeah, we basically want sort.

  6. jdoliner commented on Nov 28, 2012

    @jdoliner
    Contributor

    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.

  7. coffeemug commented on Nov 29, 2012

    @coffeemug
    Contributor

    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).

  8. wmrowan commented on Nov 29, 2012

    @wmrowan
    Contributor

    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?

  9. added a commit that references this issue on Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions