Skip to content Skip to sidebar Skip to footer

Sqlalchemy With Postgres. Try To Get 'distinct On' Instead Of 'distinct'

I need to generate query like this: SELECT **DISTINCT ON** (article.code) article.code, article.title First I try to make it via ORM distinct method and send it a list with field

Solution 1:

This bug report suggests that DISTINCT ON works correctly in SQLAlchemy 0.7+. I think an upgrade is in order, unless you've uncovered a bug in 0.7.

Workarounds . . .

  • Volunteer to help get the 0.7 package ready for Ubuntu.
  • Download and install from source.
  • Rewrite queries to avoid DISTINCT ON. I'm not sure whether that's possible in the most general case.

Post a Comment for "Sqlalchemy With Postgres. Try To Get 'distinct On' Instead Of 'distinct'"