Closed aidanlister closed 10 years ago
I guess everything is possibble if anyone works on it.
@niwibe do you think it's possible and if yes do you have a rough idea of how to accomplish it?
Hi!
As far as I know, postgresql has support for ordering over some expresion like that but, at this momment I don't know how is difficult of implement it over django orm. I need some time for research about it.
Yeah, postgresql supports it, I can't trick the ORM into using it though.
I've tried all sorts of tricks: ReportItem.objects.all().extra(select={'foo': 'extra->order_no'}, order_by=['foo'])
No deal.
With the reimplemented version of hstore hopefully coming in Django 1.8, and an expansion of custom lookups to allow use elsewhere that in filter()
and exclude()
, this this should become possible. So hopefully Django 1.8 or 1.9. However at present I can't think of a way to achieve it without raw SQL.
I would point out that without the relevant index this will be abominably slow.
@mjtamlyn thanks for the info.
it was also discussed before how to add indexes on HSTORE but we concluded that it is only possible to do it manually, what do you think?
At present yes, by hand is the only option (except db_index=True
). You can of course put the SQL in a migration which would be better.
I'm closing this as apparently it can't be solved right now.
I'd expect to be able to do something like: Model.objects.all().order_by('data->door_order_no')
Could this be implemented somehow?