Commits

Mike Bayer committed e83f3c5

- Added label() method to InstrumentedAttribute
to establish forwards compatibility with 0.5.

Comments (0)

Files changed (3)

       SessionExtension.before_flush() will take
       effect for that flush.
 
+    - Added label() method to InstrumentedAttribute 
+      to establish forwards compatibility with 0.5.
+
 - sql
     - column.in_(someselect) can now be used as 
       a columns-clause expression without the subquery

lib/sqlalchemy/orm/attributes.py

     def expression_element(self):
         return self.comparator.expression_element()
 
+    def label(self, name):
+        return self.clause_element().label(name)
+
     def operate(self, op, *other, **kwargs):
         return op(self.comparator, *other, **kwargs)
 
     def test_op(self):
         assert str(User.name.op('ilike')('17').compile(dialect=default.DefaultDialect())) == "users.name ilike :name_1"
 
+    def test_label(self):
+        assert str(User.name.label('foobar').compile() == "users.name AS foobar")
+
     def test_in(self):
          self._test(User.id.in_(['a', 'b']),
                     "users.id IN (:id_1, :id_2)")
             sess.clear()
 
         self.assertRaises(exceptions.InvalidRequestError, sess.query(User).add_column, object())
-    
+   
     def test_ambiguous_column(self):
         sess = create_session()