Skip to content

order by with raw SQL #311

Closed
Closed

Description

@ghazel

Very similar to #304 , it would be nice to be able to order by some raw (but properly escaped) SQL. My case is:

    cities.find().order("ST_Distance(geopoint, ?)", [point]).limit(1);

Two problems with this; first, it doesn't take ? and a list. Second, even a properly formed query gets quoted like it's an identifier.

Activity

  1. dxg commented on Aug 28, 2013

    @dxg
    Collaborator

    This is on the TODO list and will be implemented soon.

  2. dxg commented on Sep 10, 2013

    @dxg
    Collaborator

    This is a bit tricky if we want to reuse the order function because in this case:

    .find.order("name ASC") ...

    "name ASC" will be treated as a property name and mangled into invalid SQL, whereas

    .find.order("name ASC", []) ...

    will have a different signature and hence be treated as SQL and escaped properly.

    We might have to add another function like orderRaw or orderSql :-\

  3. added 3 commits that reference this issue on Sep 10, 2013
    6cd6313
    874a12a
    ffa0be8
  4. added a commit that references this issue on Sep 10, 2013
    ae237c4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions