order_by and func

0 views
Skip to first unread message

Eoghan Murray

unread,
Oct 22, 2009, 8:12:39 AM10/22/09
to SQLElixir
Hi,

I'd like to express an advanced order_by clause (not just a column).
At the moment I have:

OneToMany('OtherTable', order_by='field1')

I'd like to be able to put in an sql function (in this case a postgres
function) in the order_by clause, e.g.:

OneToMany('OtherTable', order_by="position(' ' in field1)")

However the elixir order_by expects column names.

What would be the easiest way around this?

Thanks!

Eoghan

Gaetan de Menten

unread,
Oct 22, 2009, 10:36:19 AM10/22/09
to sqle...@googlegroups.com

You might be able to do the sort in python (wrap the relation in a
property) but, depending on the size of the dataset, that might be too
slow...
I don't think there is any other option currently (except, of course,
moving away from Elixir to "declarative" or even "raw" SQLAlchemy).

Could you add a ticket for this in our trac?

--
Gaëtan de Menten
http://openhex.org

Reply all
Reply to author
Forward
0 new messages