From: Mike Bayer Date: Fri, 31 May 2013 15:52:31 +0000 (-0400) Subject: Fixed a regression caused by [ticket:2682] whereby the X-Git-Tag: rel_0_9_0b1~304^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2cd1a43778d4dca0846d2e50fc5934e6f5ac3738;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Fixed a regression caused by [ticket:2682] whereby the evaluation invoked by :meth:`.Query.update` and :meth:`.Query.delete` would hit upon unsupported ``True`` and ``False`` symbols which now appear due to the usage of ``IS``. [ticket:2737] --- diff --git a/doc/build/changelog/changelog_08.rst b/doc/build/changelog/changelog_08.rst index acf4ea670c..67824b8e12 100644 --- a/doc/build/changelog/changelog_08.rst +++ b/doc/build/changelog/changelog_08.rst @@ -6,6 +6,15 @@ .. changelog:: :version: 0.8.2 + .. change:: + :tags: bug, orm + :tickets: 2737 + + Fixed a regression caused by :ticket:`2682` whereby the + evaluation invoked by :meth:`.Query.update` and :meth:`.Query.delete` + would hit upon unsupported ``True`` and ``False`` symbols + which now appear due to the usage of ``IS``. + .. change:: :tags: bug, postgresql :tickets: 2735 diff --git a/lib/sqlalchemy/orm/evaluator.py b/lib/sqlalchemy/orm/evaluator.py index e8433290c8..458eab7a18 100644 --- a/lib/sqlalchemy/orm/evaluator.py +++ b/lib/sqlalchemy/orm/evaluator.py @@ -40,6 +40,12 @@ class EvaluatorCompiler(object): def visit_null(self, clause): return lambda obj: None + def visit_false(self, clause): + return lambda obj: False + + def visit_true(self, clause): + return lambda obj: True + def visit_column(self, clause): if 'parentmapper' in clause._annotations: key = clause._annotations['parentmapper'].\ diff --git a/test/orm/test_evaluator.py b/test/orm/test_evaluator.py index 4678100ebd..2570f76503 100644 --- a/test/orm/test_evaluator.py +++ b/test/orm/test_evaluator.py @@ -62,6 +62,23 @@ class EvaluateTest(fixtures.MappedTest): (User(name=None), True), ]) + def test_true_false(self): + User = self.classes.User + + eval_eq(User.name == False, testcases=[ + (User(name='foo'), False), + (User(name=True), False), + (User(name=False), True), + ] + ) + + eval_eq(User.name == True, testcases=[ + (User(name='foo'), False), + (User(name=True), True), + (User(name=False), False), + ] + ) + def test_boolean_ops(self): User = self.classes.User