EliAndrewC / sideboard

BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Crud._distinct_query should work in backends other than postgresql #20

Closed EliAndrewC closed 8 years ago

EliAndrewC commented 10 years ago

In our tested version of SQLAlchemy, the http://docs.sqlalchemy.org/en/rel_0_8/orm/query.html#sqlalchemy.orm.query.Query.distinct method only works on specific columns with Postgresql. This means that there's a significant difference between the two forms of distinct that sqlalchemy supports:

>>> [tag.name for tag in session.query(Tag).all()]
[u'Male', u'Male', u'Ninja', u'Pirate']
>>> session.query(Tag).distinct(Tag.name).count()
4
>>> session.query(Tag.name).distinct().count()
3

This is probably fine as long as we document this; we're personally using postgresql everywhere where we'd care, but it would be nice to not have this restriction. This would require a small but non-trivial rewrite to how we're performing these queries, and we should un-skip the relevant tests.

Now that Sideboard is open source, this is a little more crucial since it introduces a "some of sideboard.lib.sa won't work with MySQL" caveat which we'd probably rather not have.

EliAndrewC commented 8 years ago

Moved to https://github.com/magfest/sideboard/issues/40