0

I'm using the Sequel library in Ruby by Jeremy Evans and I'm trying to order by a field in json.

I can get this to work in SQL with this Postgres query:

SELECT * FROM files ORDER BY json->>'filename' ASC

but i can't get this to work with Sequel/Postgres

table.order("json ->'filename'")

This results in the following SQL:

SELECT * FROM "files" ORDER BY 'json ->''filename'''

giving the error:

PG::SyntaxError: ERROR: non-integer constant in ORDER BY LINE 1: ... ORDER BY 'json ->''...

1 Answer 1

2

Problem solved:

table.order(Sequel.lit("json ->'filename'"))

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.