diff options
author | Jason Kirtland <jek@discorporate.us> | 2007-08-09 18:31:59 +0000 |
---|---|---|
committer | Jason Kirtland <jek@discorporate.us> | 2007-08-09 18:31:59 +0000 |
commit | cb9356070dc9d64af4e146db2889d1d3341b9b6c (patch) | |
tree | 64b612ec200b6cba75f18ac499a88fdeb2fe1bd1 | |
parent | 0cca04a8922418130a30003f0c518b77548353a9 (diff) | |
download | sqlalchemy-cb9356070dc9d64af4e146db2889d1d3341b9b6c.tar.gz |
tweak DISTINCT precedence for clauses like `func.count(t.c.col.distinct())`
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | lib/sqlalchemy/sql.py | 1 | ||||
-rw-r--r-- | test/sql/select.py | 8 |
3 files changed, 12 insertions, 0 deletions
@@ -1,4 +1,7 @@ 0.3.11 +- sql + - tweak DISTINCT precedence for clauses like + `func.count(t.c.col.distinct())` - orm - added a check for joining from A->B using join(), along two different m2m tables. this raises an error in 0.3 but is diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py index 8b454947e..3233aad68 100644 --- a/lib/sqlalchemy/sql.py +++ b/lib/sqlalchemy/sql.py @@ -63,6 +63,7 @@ PRECEDENCE = { '>=':5, '<=':5, 'BETWEEN':5, + 'DISTINCT':5, 'NOT':4, 'AND':3, 'OR':2, diff --git a/test/sql/select.py b/test/sql/select.py index 4d3eb4ad7..030bf44dc 100644 --- a/test/sql/select.py +++ b/test/sql/select.py @@ -259,6 +259,14 @@ sq.myothertable_othername AS sq_myothertable_othername FROM (" + sqstring + ") A self.runtest( select([distinct(table1.c.myid)]), "SELECT DISTINCT mytable.myid FROM mytable" ) + + self.runtest( + select([func.count(table1.c.myid.distinct())]), "SELECT count(DISTINCT mytable.myid) FROM mytable" + ) + + self.runtest( + select([func.count(distinct(table1.c.myid))]), "SELECT count(DISTINCT mytable.myid) FROM mytable" + ) def testoperators(self): self.runtest( |