]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Added label() method to InstrumentedAttribute
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 17 Sep 2008 19:31:24 +0000 (19:31 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 17 Sep 2008 19:31:24 +0000 (19:31 +0000)
to establish forwards compatibility with 0.5.

CHANGES
lib/sqlalchemy/orm/attributes.py
test/orm/query.py

diff --git a/CHANGES b/CHANGES
index d84aaff7d8b138dbc11b9ab43610942ca9e69f9b..206d2cb5fa5b24672feb27cd0b37f080a1dc11b6 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -13,6 +13,9 @@ CHANGES
       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
index fb0621a70f5320b861f17cd49e59e7867cba1c6b..331ba365947e3160ff7cc46fbce743f8401f6267 100644 (file)
@@ -52,6 +52,9 @@ class InstrumentedAttribute(interfaces.PropComparator):
     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)
 
index 87af4063c51d9bca82e09d737e6ed6e2dac20133..dad3b95d228bf71550b7de30455970f63343688a 100644 (file)
@@ -249,6 +249,9 @@ class OperatorTest(QueryTest):
     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)")
@@ -1132,7 +1135,7 @@ class InstancesTest(QueryTest, AssertsCompiledSQL):
             sess.clear()
 
         self.assertRaises(exceptions.InvalidRequestError, sess.query(User).add_column, object())
-    
+   
     def test_ambiguous_column(self):
         sess = create_session()