From a341e1ccc9b4d12906f8cb423c45ac2f6f754891 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 8 Jun 2013 13:39:20 -0400 Subject: [PATCH] also clarified the changelog regarding Cls.scalar != 'value' --- doc/build/changelog/changelog_09.rst | 8 +++++++- test/ext/test_associationproxy.py | 22 +++++++++++----------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index 0ae1a23223..10921476b0 100644 --- a/doc/build/changelog/changelog_09.rst +++ b/doc/build/changelog/changelog_09.rst @@ -21,7 +21,13 @@ inverse operation ``Cls.scalar != None`` *would* return ``Cls`` rows for which ``Cls.associated`` was non-present. - Additionally, added a special use case where you + The case for ``Cls.scalar != 'somevalue'`` is also modified + to act more like a direct SQL comparison; only rows for + which ``Cls.associated`` is present and ``Associated.scalar`` + is non-NULL and not equal to ``'somevalue'`` are returned. + Previously, this would be a simple ``NOT EXISTS``. + + Also added a special use case where you can call ``Cls.scalar.has()`` with no arguments, when ``Cls.scalar`` is a column-based value - this returns whether or not ``Cls.associated`` has any rows present, regardless of whether diff --git a/test/ext/test_associationproxy.py b/test/ext/test_associationproxy.py index 724f1b215a..4cfb58481c 100644 --- a/test/ext/test_associationproxy.py +++ b/test/ext/test_associationproxy.py @@ -1306,6 +1306,17 @@ class ComparatorTest(fixtures.MappedTest, AssertsCompiledSQL): ) ) + def test_filter_ne_value_nul(self): + User = self.classes.User + Singular = self.classes.Singular + + self._equivalent( + self.session.query(User).filter(User.singular_value != "singular4"), + self.session.query(User).filter( + User.singular.has(Singular.value != "singular4"), + ) + ) + def test_filter_eq_value_nul(self): User = self.classes.User Singular = self.classes.Singular @@ -1377,17 +1388,6 @@ class ComparatorTest(fixtures.MappedTest, AssertsCompiledSQL): User.singular_value.has, singular_value="singular4" ) - def test_filter_ne_value_nul(self): - User = self.classes.User - Singular = self.classes.Singular - - self._equivalent( - self.session.query(User).filter(User.singular_value != "singular4"), - self.session.query(User).filter( - User.singular.has(Singular.value != "singular4"), - ) - ) - def test_filter_scalar_contains_fails_nul_nul(self): Keyword = self.classes.Keyword -- 2.47.3