>
> Which is good. I'd like the select to be modified to have a "DISTINCT
> ON (pw_entries.eid, pw_entries.uname, pw_entries.uid)" before the rest
> of the columns, something like this:
>
> SELECT DISTINCT ON (pw_entries.eid, pw_entries.uname, pw_entries.uid)
> pw_entries.domain_id AS pw_entries_domain_id,
>
> I've tried adding a distinct() call with an array argument, that
> didn't work.
>
> I've also tried putting a select(distinct=[..]) call in the chain with
> no luck.
>
we support a "distinct()" operator which should acheive this, but
looking at the PG source code it is not correctly implemented. There
seems to be an extension to the "distinct" keyword argument with PG
which works like this:
select(...., distinct=[<list of expressions>])
That should work in 0.4, though this seems to be very old code without
unit tests. In 0.5, I'm really not sure I like that so look for a
possible change of that to: select([distinct(<list of exprs>)])
(ticket:1069)
> print pwEntries.query().filter(
> or_(*ors)
> ).order_by
> (func.lower(pwEntries.eid).desc()).order_by(pwEntries.uname).compile()
>
reading further, it seems like "DISTINCT ON" doesn't even work the way
it does in MySQL - theres no comma between the DISTINCT_ON portion of
things and the rest of the columns and it is not actually returning
columns....so my notion of using select([distinct(...)]) is not
appropraite here. Additionally, you're trying to do this with ORM
and Query only has a "distinct()" method which does the regular SQL
form of "DISTINCT".
I think the only way this would be possible in ORM for the time being
is query.from_statement(<statement>), where <statement> is a select()
construct or a full text string. the solution for select() /query()
would be adding arguments to (select()/query()).distinct().
yeah thats what I think needs to be done here (ticket is updated).