From: Mike Bayer Date: Sat, 8 Jun 2013 17:39:20 +0000 (-0400) Subject: also clarified the changelog regarding Cls.scalar != 'value' X-Git-Tag: rel_0_9_0b1~286 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a341e1ccc9b4d12906f8cb423c45ac2f6f754891;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git also clarified the changelog regarding Cls.scalar != 'value' --- 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