diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2016-06-06 15:57:06 -0400 |
|---|---|---|
| committer | Gerrit Code Review <gerrit2@ln3.zzzcomputing.com> | 2016-06-06 15:57:06 -0400 |
| commit | 2860ae6c4927dbbca9316c81ce15cbbb7df49750 (patch) | |
| tree | 1a4125880b200c9b4fe2ce2d5d3f6a5332f4c7b6 /test/sql | |
| parent | bc4c6c44af6681ade49892d46dadb04f141f5450 (diff) | |
| parent | 3351f5f93ca1968653becbed7f1ddef7afb96077 (diff) | |
| download | sqlalchemy-2860ae6c4927dbbca9316c81ce15cbbb7df49750.tar.gz | |
Merge "Add IS (NOT) DISTINCT FROM operators"
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_operators.py | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py index 86286a9a3..5712d8f99 100644 --- a/test/sql/test_operators.py +++ b/test/sql/test_operators.py @@ -99,6 +99,18 @@ class DefaultColumnComparatorTest(fixtures.TestBase): def test_notequals_true(self): self._do_operate_test(operators.ne, True) + def test_is_distinct_from_true(self): + self._do_operate_test(operators.is_distinct_from, True) + + def test_is_distinct_from_false(self): + self._do_operate_test(operators.is_distinct_from, False) + + def test_is_distinct_from_null(self): + self._do_operate_test(operators.is_distinct_from, None) + + def test_isnot_distinct_from_true(self): + self._do_operate_test(operators.isnot_distinct_from, True) + def test_is_true(self): self._do_operate_test(operators.is_, True) @@ -1527,6 +1539,60 @@ class OperatorAssociativityTest(fixtures.TestBase, testing.AssertsCompiledSQL): self.assert_compile(f / (f / (f - f)), "f / (f / (f - f))") +class IsDistinctFromTest(fixtures.TestBase, testing.AssertsCompiledSQL): + __dialect__ = 'default' + + table1 = table('mytable', + column('myid', Integer), + ) + + def test_is_distinct_from(self): + self.assert_compile(self.table1.c.myid.is_distinct_from(1), + "mytable.myid IS DISTINCT FROM :myid_1") + + def test_is_distinct_from_sqlite(self): + self.assert_compile(self.table1.c.myid.is_distinct_from(1), + "mytable.myid IS NOT ?", + dialect=sqlite.dialect()) + + def test_is_distinct_from_postgresql(self): + self.assert_compile(self.table1.c.myid.is_distinct_from(1), + "mytable.myid IS DISTINCT FROM %(myid_1)s", + dialect=postgresql.dialect()) + + def test_not_is_distinct_from(self): + self.assert_compile(~self.table1.c.myid.is_distinct_from(1), + "mytable.myid IS NOT DISTINCT FROM :myid_1") + + def test_not_is_distinct_from_postgresql(self): + self.assert_compile(~self.table1.c.myid.is_distinct_from(1), + "mytable.myid IS NOT DISTINCT FROM %(myid_1)s", + dialect=postgresql.dialect()) + + def test_isnot_distinct_from(self): + self.assert_compile(self.table1.c.myid.isnot_distinct_from(1), + "mytable.myid IS NOT DISTINCT FROM :myid_1") + + def test_isnot_distinct_from_sqlite(self): + self.assert_compile(self.table1.c.myid.isnot_distinct_from(1), + "mytable.myid IS ?", + dialect=sqlite.dialect()) + + def test_isnot_distinct_from_postgresql(self): + self.assert_compile(self.table1.c.myid.isnot_distinct_from(1), + "mytable.myid IS NOT DISTINCT FROM %(myid_1)s", + dialect=postgresql.dialect()) + + def test_not_isnot_distinct_from(self): + self.assert_compile(~self.table1.c.myid.isnot_distinct_from(1), + "mytable.myid IS DISTINCT FROM :myid_1") + + def test_not_isnot_distinct_from_postgresql(self): + self.assert_compile(~self.table1.c.myid.isnot_distinct_from(1), + "mytable.myid IS DISTINCT FROM %(myid_1)s", + dialect=postgresql.dialect()) + + class InTest(fixtures.TestBase, testing.AssertsCompiledSQL): __dialect__ = 'default' |
