]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
lazy load bind params properly propigate column type [ticket:225]
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 27 Jun 2006 21:48:53 +0000 (21:48 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 27 Jun 2006 21:48:53 +0000 (21:48 +0000)
CHANGES
lib/sqlalchemy/orm/properties.py
test/orm/objectstore.py

diff --git a/CHANGES b/CHANGES
index 1f94c6eee7262bc379acc86bbaddd12bb9cde8bd..b37f942db26083f67517716fec5935d9f574d0e0 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -30,6 +30,7 @@ causing a reentrant hang unless threading.RLock is used.
 if it has a foreign key constraint
 - cursor() method on ConnectionFairy allows db-specific extension
 arguments to be propigated [ticket:221]
+- lazy load bind params properly propigate column type [ticket:225]
 
 0.2.3
 - overhaul to mapper compilation to be deferred.  this allows mappers
index 6be5633932c4f877b03de2415cbc81a5942fe4e8..f0ec8f5568d5b22c0244ed68f038e09927a90c20 100644 (file)
@@ -423,13 +423,13 @@ def create_lazy_clause(table, primaryjoin, secondaryjoin, foreignkey):
         if isinstance(binary.left, schema.Column) and isinstance(binary.right, schema.Column) and ((not circular and binary.left.table is table) or (circular and binary.right in foreignkey)):
             col = binary.left
             binary.left = binds.setdefault(binary.left,
-                    sql.BindParamClause(bind_label(), None, shortname = binary.left.name))
+                    sql.BindParamClause(bind_label(), None, shortname=binary.left.name, type=binary.right.type))
             reverse[binary.right] = binds[col]
 
         if isinstance(binary.right, schema.Column) and isinstance(binary.left, schema.Column) and ((not circular and binary.right.table is table) or (circular and binary.left in foreignkey)):
             col = binary.right
             binary.right = binds.setdefault(binary.right,
-                    sql.BindParamClause(bind_label(), None, shortname = binary.right.name))
+                    sql.BindParamClause(bind_label(), None, shortname=binary.right.name, type=binary.left.type))
             reverse[binary.left] = binds[col]
             
     lazywhere = primaryjoin.copy_container()
index e897d84a8a448c16a7599a64771437dba228c630..18c64e93650839dbd8173d20e3c95321efc439f5 100644 (file)
@@ -178,15 +178,22 @@ class VersioningTest(SessionTest):
 class UnicodeTest(SessionTest):
     def setUpAll(self):
         SessionTest.setUpAll(self)
-        global uni_table
-        uni_table = Table('uni_test', db,
+        global metadata, uni_table, uni_table2
+        metadata = BoundMetaData(testbase.db)
+        uni_table = Table('uni_test', metadata,
             Column('id',  Integer, primary_key=True),
-            Column('txt', Unicode(50))).create()
-
+            Column('txt', Unicode(50), unique=True))
+        uni_table2 = Table('uni2', metadata,
+            Column('id',  Integer, primary_key=True),
+            Column('txt', Unicode(50), ForeignKey(uni_table.c.txt)))
+        metadata.create_all()
     def tearDownAll(self):
-        uni_table.drop()
+        metadata.drop_all()
         SessionTest.tearDownAll(self)
-
+    def tearDown(self):
+        clear_mappers()
+        for t in metadata.table_iterator(reverse=True):
+            t.delete().execute()
     def testbasic(self):
         class Test(object):
             def __init__(self, id, txt):
@@ -199,8 +206,26 @@ class UnicodeTest(SessionTest):
         self.assert_(t1.txt == txt)
         ctx.current.flush()
         self.assert_(t1.txt == txt)
-
-
+    def testrelation(self):
+        class Test(object):
+            def __init__(self, txt):
+                self.txt = txt
+        class Test2(object):pass
+            
+        mapper(Test, uni_table, properties={
+            't2s':relation(Test2)
+        })
+        mapper(Test2, uni_table2)
+            
+        txt = u"\u0160\u0110\u0106\u010c\u017d"
+        t1 = Test(txt=txt)
+        t1.t2s.append(Test2())
+        t1.t2s.append(Test2())
+        ctx.current.flush()
+        ctx.current.clear()
+        t1 = ctx.current.query(Test).get_by(id=t1.id)
+        assert len(t1.t2s) == 2
+        
 class PKTest(SessionTest):
     def setUpAll(self):
         SessionTest.setUpAll(self)