diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-09-08 20:28:26 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-09-08 20:28:26 +0000 |
| commit | 8c14291b6d634604a6da3bbc9c965e0de3084933 (patch) | |
| tree | 3d558e3550e6a3bf41b3f73a1bf29a2ee77714f7 /test/sql/select.py | |
| parent | 5ba8a25afe9c4b84b74d5e51a641992b5d44097a (diff) | |
| download | sqlalchemy-8c14291b6d634604a6da3bbc9c965e0de3084933.tar.gz | |
- adjusted operator precedence of NOT to match '==' and others, so that
~(x <operator> y) produces NOT (x <op> y), which is better compatible with MySQL.
[ticket:764]. this doesn't apply to "~(x==y)" as it does in 0.3 since ~(x==y)
compiles to "x != y", but still applies to operators like BETWEEN.
Diffstat (limited to 'test/sql/select.py')
| -rw-r--r-- | test/sql/select.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/test/sql/select.py b/test/sql/select.py index 6a8131046..1114f1735 100644 --- a/test/sql/select.py +++ b/test/sql/select.py @@ -339,7 +339,6 @@ sq.myothertable_othername AS sq_myothertable_othername FROM (" + sqstring + ") A ) def testoperators(self): - # exercise arithmetic operators for (py_op, sql_op) in ((operator.add, '+'), (operator.mul, '*'), (operator.sub, '-'), (operator.div, '/'), @@ -390,6 +389,11 @@ sq.myothertable_othername AS sq_myothertable_othername FROM (" + sqstring + ") A ) self.assert_compile( + table1.select((table1.c.myid != 12) & ~(table1.c.name.between('jack','john'))), + "SELECT mytable.myid, mytable.name, mytable.description FROM mytable WHERE mytable.myid != :mytable_myid AND NOT (mytable.name BETWEEN :mytable_name AND :mytable_name_1)" + ) + + self.assert_compile( table1.select((table1.c.myid != 12) & ~and_(table1.c.name=='john', table1.c.name=='ed', table1.c.name=='fred')), "SELECT mytable.myid, mytable.name, mytable.description FROM mytable WHERE mytable.myid != :mytable_myid AND NOT (mytable.name = :mytable_name AND mytable.name = :mytable_name_1 AND mytable.name = :mytable_name_2)" ) @@ -1083,6 +1087,10 @@ UNION SELECT mytable.myid, mytable.name, mytable.description FROM mytable WHERE "SELECT op.field FROM op WHERE :op_field + op.field IN (:literal, :literal_1)") self.assert_compile(table.select(not_(and_(table.c.field == 5, table.c.field == 7))), "SELECT op.field FROM op WHERE NOT (op.field = :op_field AND op.field = :op_field_1)") + self.assert_compile(table.select(not_(table.c.field == 5)), + "SELECT op.field FROM op WHERE op.field != :op_field") + self.assert_compile(table.select(not_(table.c.field.between(5, 6))), + "SELECT op.field FROM op WHERE NOT (op.field BETWEEN :op_field AND :op_field_1)") self.assert_compile(table.select(not_(table.c.field) == 5), "SELECT op.field FROM op WHERE (NOT op.field) = :literal") self.assert_compile(table.select((table.c.field == table.c.field).between(False, True)), |
