]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- id(obj) is no longer used internally within topological.py,
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 1 Apr 2010 16:45:51 +0000 (12:45 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 1 Apr 2010 16:45:51 +0000 (12:45 -0400)
as the sorting functions now require hashable objects
only.  [ticket:1756]

CHANGES
lib/sqlalchemy/sql/util.py
lib/sqlalchemy/topological.py

diff --git a/CHANGES b/CHANGES
index 39bba20bbfa27d6bccdda37839b2b8922631e49d..f22905f267b5086fb803119c3de90e4d70cce745 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -30,6 +30,10 @@ CHANGES
   - Fixed a potential issue in topological cycle detection 
     introduced in 0.6beta3, for units of work with long 
     dependency cycles.
+
+  - id(obj) is no longer used internally within topological.py,
+    as the sorting functions now require hashable objects
+    only.  [ticket:1756]
     
 - sql
   - Restored some bind-labeling logic from 0.5 which ensures
index d5575e0e73e7f546428e9208adc28f08a6f017a0..5a439b099dd9d0ff3f40d593e578612c2ea17aef 100644 (file)
@@ -15,7 +15,8 @@ def sort_tables(tables):
         parent_table = fkey.column.table
         if parent_table in tables:
             child_table = fkey.parent.table
-            tuples.append( ( parent_table, child_table ) )
+            if parent_table is not child_table:
+                tuples.append((parent_table, child_table))
 
     for table in tables:
         visitors.traverse(table, {'schema_visitor':True}, {'foreign_key':visit_foreign_key})    
index 9e584ff4e06fda8ab39df2adfd48226911a9e9ba..d061aec043b13fd84d6c9970b2dd0995ac1c7c1d 100644 (file)
@@ -161,21 +161,20 @@ def _sort(tuples, allitems, allow_cycles=False, ignore_self_cycles=False):
     edges = _EdgeCollection()
 
     for item in list(allitems) + [t[0] for t in tuples] + [t[1] for t in tuples]:
-        item_id = id(item)
-        if item_id not in nodes:
-            nodes[item_id] = _Node(item)
+        if item not in nodes:
+            nodes[item] = _Node(item)
 
     for t in tuples:
-        id0, id1 = id(t[0]), id(t[1])
-        if t[0] is t[1]:
+        t0, t1 = t[0], t[1]
+        if t0 is t1:
             if allow_cycles:
-                n = nodes[id0]
+                n = nodes[t0]
                 n.cycles = set([n])
             elif not ignore_self_cycles:
                 raise CircularDependencyError("Self-referential dependency detected: %r" % t)
             continue
-        childnode = nodes[id1]
-        parentnode = nodes[id0]
+        childnode = nodes[t1]
+        parentnode = nodes[t0]
         edges.add((parentnode, childnode))
 
     queue = []
@@ -207,11 +206,11 @@ def _sort(tuples, allitems, allow_cycles=False, ignore_self_cycles=False):
                 continue
             else:
                 # long cycles not allowed
-                raise CircularDependencyError("Circular dependency detected: %r %r " % (edges, queue))
+                raise CircularDependencyError("Circular dependency detected: %r" % edges)
         node = queue.pop()
         if not hasattr(node, '_cyclical'):
             output.append(node)
-        del nodes[id(node.item)]
+        del nodes[node.item]
         for childnode in edges.pop_node(node):
             queue.append(childnode)
     return output