Skip to content
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

order by with raw SQL #311

Closed
ghazel opened this issue Aug 22, 2013 · 2 comments · Fixed by #332
Closed

order by with raw SQL #311

ghazel opened this issue Aug 22, 2013 · 2 comments · Fixed by #332
Labels

Comments

@ghazel
Copy link

ghazel commented Aug 22, 2013

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.

@dxg
Copy link
Collaborator

dxg commented Aug 28, 2013

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

@dxg
Copy link
Collaborator

dxg commented Sep 10, 2013

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 :-\

dxg added a commit that referenced this issue Sep 10, 2013
dxg added a commit that referenced this issue Sep 10, 2013
dxg added a commit that referenced this issue Sep 10, 2013
@dxg dxg closed this as completed in #332 Sep 10, 2013
dxg added a commit that referenced this issue Sep 10, 2013
Allow ordering by escaped sql
Closes #311
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants