sql - Rails ordering with nil last - SQLite3 error -
currently, trying order class limit
attribute. want values in ascending order, nil
values last.
i've tried couple different queries activerecord query along cross base sql query (it needs sql flexible). i've tried few:
self.order('isnull(limit), limit asc') self.order('case when -limit desc') self.order('limit null, limit desc')
but keep getting errors around limit
, missing something?
sqlite3::sqlexception: near "isnull": syntax error: select "table".* "table" "table"."deleted_at" null order isnull(limit), limit asc
limit null
it, limit
reserved keywork in sqlite3, enclose in backticks or quotes:
self.order('`limit` null')