]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Backported a change from 0.9 whereby the iteration of a hierarchy
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 18 Aug 2013 19:57:06 +0000 (15:57 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 18 Aug 2013 19:57:06 +0000 (15:57 -0400)
of mappers used in polymorphic inheritance loads is sorted on class name,
which allows the SELECT statements generated for polymorphic queries
to have deterministic rendering, which in turn helps with caching
schemes that cache on the SQL string itself.
[ticket:2779]

doc/build/changelog/changelog_08.rst
lib/sqlalchemy/orm/mapper.py

index d67c088eb1cac721b2473fb6779480dc742c240f..3bfd817f1f2959e1a79023bbd6e452edfa8d39ac 100644 (file)
@@ -6,6 +6,16 @@
 .. changelog::
     :version: 0.8.3
 
+    .. change::
+        :tags: bug, orm
+        :tickets: 2779
+
+        Backported a change from 0.9 whereby the iteration of a hierarchy
+        of mappers used in polymorphic inheritance loads is sorted on class name,
+        which allows the SELECT statements generated for polymorphic queries
+        to have deterministic rendering, which in turn helps with caching
+        schemes that cache on the SQL string itself.
+
     .. change::
         :tags: bug, orm
         :tickets: 2794
index ff235eaf08665116b6d81a2fb91156eabe78a86c..e5c9a05c2e3fb51bb6e92ed3bb247abb319e64e6 100644 (file)
@@ -1798,7 +1798,8 @@ class Mapper(_InspectionAttr):
         while stack:
             item = stack.popleft()
             descendants.append(item)
-            stack.extend(item._inheriting_mappers)
+            stack.extend(sorted(item._inheriting_mappers,
+                        key=lambda m: m.class_.__name__))
         return util.WeakSequence(descendants)
 
     def polymorphic_iterator(self):