annotations bug

Issue #2660 resolved
Mike Bayer repo owner created an issue
from sqlalchemy.sql import column

c = column('x')

c == 5

c1 = c._annotate({"x": True})
c1 == 5

c2 = c1._annotate({"y": True})

assert (c2 == 5).left._annotations == {"x": True, "y": True}

patch:

diff -r acb9ded7c87d30446c19c825aa8fd373827f1040 lib/sqlalchemy/sql/util.py
--- a/lib/sqlalchemy/sql/util.py    Sat Feb 02 18:59:19 2013 -0500
+++ b/lib/sqlalchemy/sql/util.py    Sat Feb 02 19:49:44 2013 -0500
@@ -449,7 +449,7 @@
     def _with_annotations(self, values):
         clone = self.__class__.__new__(self.__class__)
         clone.__dict__ = self.__dict__.copy()
-        expression.ColumnElement.comparator._reset(self)
+        expression.ColumnElement.comparator._reset(clone)
         clone._annotations = values
         return clone

this is related to a fix coming up for #1768

Comments (2)

  1. Log in to comment