]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- fixed "remote_side" in testrelationonbaseclass [ticket:461]
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 6 Feb 2007 19:22:44 +0000 (19:22 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 6 Feb 2007 19:22:44 +0000 (19:22 +0000)
- added --reversetop arg to testbase to allow reversing the input collection
for topological sorts, to better reveal dependency issues

test/orm/inheritance5.py
test/testbase.py

index 8a0c909afac521e1dd664e4ea6b69ef965ad7e67..6c093bf9ddcb9df67a26addcd5b553af2d256fb4 100644 (file)
@@ -6,7 +6,7 @@ class AttrSettable(object):
     def __init__(self, **kwargs):
         [setattr(self, k, v) for k, v in kwargs.iteritems()]
     def __repr__(self):
-        return self.__class__.__name__ + ' ' + ','.join(["%s=%s" % (k,v) for k, v in self.__dict__.iteritems() if k[0] != '_'])
+        return self.__class__.__name__ + "(%s)" % (hex(id(self)))
 
 
 class RelationTest1(testbase.ORMTest):
@@ -233,7 +233,7 @@ class RelationTest3(testbase.ORMTest):
         if usedata:
             mapper(Person, people, select_table=poly_union, polymorphic_identity='person', polymorphic_on=people.c.type,
                   properties={
-                    'colleagues':relation(Person, primaryjoin=people.c.colleague_id==people.c.person_id, remote_side=people.c.colleague_id, uselist=True),
+                    'colleagues':relation(Person, primaryjoin=people.c.colleague_id==people.c.person_id, remote_side=people.c.person_id, uselist=True),
                     'data':relation(Data, uselist=False)
                     }        
             )
@@ -241,7 +241,7 @@ class RelationTest3(testbase.ORMTest):
             mapper(Person, people, select_table=poly_union, polymorphic_identity='person', polymorphic_on=people.c.type,
                   properties={
                     'colleagues':relation(Person, primaryjoin=people.c.colleague_id==people.c.person_id, 
-                        remote_side=people.c.colleague_id, uselist=True)
+                        remote_side=people.c.person_id, uselist=True)
                     }        
             )
 
index bc5153af0e9e42474e5db08c90a96ce1bd91ef88..b35c5e7ff44cdd4c650799cb062671fad2203cba 100644 (file)
@@ -51,7 +51,8 @@ def parse_argv():
     parser.add_option("--nothreadlocal", action="store_true", dest="nothreadlocal", help="dont use thread-local mod")
     parser.add_option("--enginestrategy", action="store", default=None, dest="enginestrategy", help="engine strategy (plain or threadlocal, defaults to plain)")
     parser.add_option("--coverage", action="store_true", dest="coverage", help="Dump a full coverage report after running")
-
+    parser.add_option("--reversetop", action="store_true", dest="topological", help="Reverse the collection ordering for topological sorts (helps reveal dependency issues)")
+    
     (options, args) = parser.parse_args()
     sys.argv[1:] = args
     
@@ -106,7 +107,19 @@ def parse_argv():
     else:
         db = engine.create_engine(db_uri, **db_opts)
     db = EngineAssert(db)
-
+    
+    if options.topological:
+        from sqlalchemy.orm import unitofwork
+        from sqlalchemy import topological
+        class RevQueueDepSort(topological.QueueDependencySorter):
+            def __init__(self, tuples, allitems):
+                self.tuples = list(tuples)
+                self.allitems = list(allitems)
+                self.tuples.reverse()
+                self.allitems.reverse()
+        topological.QueueDependencySorter = RevQueueDepSort
+        unitofwork.DependencySorter = RevQueueDepSort
+            
     import logging
     logging.basicConfig()
     if options.log_info is not None: