Commits

Mike Bayer  committed b22aa42

Ensure RowTuple names are correct by adding "key" to QueryableAttribute.

  • Participants
  • Parent commits 0c7564f

Comments (0)

Files changed (3)

File lib/sqlalchemy/orm/attributes.py

           comparator
             a sql.Comparator to which class-level compare/math events will be sent
         """
-
+        self.key = key
         self.impl = impl
         self.comparator = comparator
         self.parententity = parententity
             self._parententity = parententity
             self.impl = _ProxyImpl(key)
 
-        @property
+        @util.memoized_property
         def comparator(self):
             if util.callable(self._comparator):
                 self._comparator = self._comparator()
                             attribute)
                     )
 
-        def _property(self):
-            return self._parententity.get_property(self.key, resolve_synonyms=True)
-        property = property(_property)
-
     Proxy.__name__ = type(descriptor).__name__ + 'Proxy'
 
     util.monkeypatch_proxied_specials(Proxy, type(descriptor),

File lib/sqlalchemy/orm/query.py

             column = sql.literal_column(column)
             self._result_label = column.name
         elif isinstance(column, attributes.QueryableAttribute):
-            self._result_label = column.property.key
+            self._result_label = column.key
             column = column.__clause_element__()
         else:
             self._result_label = getattr(column, 'key', None)

File test/orm/mapper.py

         assert User.adlist.property
         
         sess = create_session()
+        
+        # test RowTuple names
+        row = sess.query(User.id, User.uname).first()
+        assert row.uname == row[1]
+        
         u = sess.query(User).filter(User.uname=='jack').one()
 
         fixture = self.static.user_address_result[0].addresses