]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
merged -r6112:6134 of trunk
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 18 Jul 2009 21:01:32 +0000 (21:01 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 18 Jul 2009 21:01:32 +0000 (21:01 +0000)
CHANGES
lib/sqlalchemy/orm/identity.py
lib/sqlalchemy/sql/expression.py
test/sql/test_generative.py

diff --git a/CHANGES b/CHANGES
index 97bc08b1288a1f46f69a4da88cb68f1dcd0a1944..c6cb0ff2c7e7fe02a668ac61cbf2a51163a3c117 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -3,7 +3,14 @@
 =======
 CHANGES
 =======
-
+0.5.6
+=====
+- sql
+    - Fixed a bug in extract() introduced in 0.5.4 whereby
+      the string "field" argument was getting treated as a 
+      ClauseElement, causing various errors within more 
+      complex SQL transformations.
+      
 0.5.5
 =======
 - general
index 1af0c0c9a9035abedce60fdd1006714f0d4e949f..4f2e8450be83a890f85203fc4576b4305d7d88d8 100644 (file)
@@ -43,17 +43,18 @@ class IdentityMap(dict):
         del state._instance_dict
         self._mutable_attrs.discard(state)
         self._modified.discard(state)
-    
+
     def _dirty_states(self):
-        return self._modified.union(s for s in self._mutable_attrs if s.modified)
-        
+        return self._modified.union(s for s in list(self._mutable_attrs)
+                                    if s.modified)
+
     def check_modified(self):
         """return True if any InstanceStates present have been marked as 'modified'."""
         
         if self._modified:
             return True
         else:
-            for state in self._mutable_attrs:
+            for state in list(self._mutable_attrs):
                 if state.modified:
                     return True
         return False
index 519c2cacc39da6271aff71453dc9f2160fc48357..68117ee4b5d650d556be861a45ec6f083213a4a5 100644 (file)
@@ -2424,11 +2424,10 @@ class _Extract(ColumnElement):
         self.expr = _literal_as_binds(expr, None)
 
     def _copy_internals(self, clone=_clone):
-        self.field = clone(self.field)
         self.expr = clone(self.expr)
 
     def get_children(self, **kwargs):
-        return self.field, self.expr
+        return self.expr,
 
     @property
     def _from_objects(self):
index ca427ca5f57d5043c0c6ce127f1965d1239ba77b..7c094c26b05bf9f143f03925b8dad11c6d1f2a66 100644 (file)
@@ -310,7 +310,17 @@ class ClauseTest(TestBase, AssertsCompiledSQL):
         "table1.col3 AS col3 FROM table1 WHERE table1.col1 = :col1_1) AS anon_1, "\
         "(SELECT table1.col1 AS col1, table1.col2 AS col2, table1.col3 AS col3 FROM table1 WHERE table1.col1 = :col1_2) AS anon_2 "\
         "WHERE anon_1.col2 = anon_2.col2")
-
+    
+    def test_extract(self):
+        s = select([extract('foo', t1.c.col1).label('col1')])
+        self.assert_compile(s, "SELECT EXTRACT(foo FROM table1.col1) AS col1 FROM table1")
+        
+        s2 = CloningVisitor().traverse(s).alias()
+        s3 = select([s2.c.col1])
+        self.assert_compile(s, "SELECT EXTRACT(foo FROM table1.col1) AS col1 FROM table1")
+        self.assert_compile(s3, "SELECT anon_1.col1 FROM (SELECT EXTRACT(foo FROM table1.col1) AS col1 FROM table1) AS anon_1")
+        
+        
     @testing.emits_warning('.*replaced by another column with the same key')
     def test_alias(self):
         subq = t2.select().alias('subq')