summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-06-27 21:48:53 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-06-27 21:48:53 +0000
commit00844ac4df6bbfd852c30a24ef66710a17b9ffc2 (patch)
tree691fe98cead218e3e383e67145d2915bb5c05c34
parent662bd40300e1f55a60cb5055293e96f7a50a78ea (diff)
downloadsqlalchemy-00844ac4df6bbfd852c30a24ef66710a17b9ffc2.tar.gz
lazy load bind params properly propigate column type [ticket:225]
-rw-r--r--CHANGES1
-rw-r--r--lib/sqlalchemy/orm/properties.py4
-rw-r--r--test/orm/objectstore.py41
3 files changed, 36 insertions, 10 deletions
diff --git a/CHANGES b/CHANGES
index 1f94c6eee..b37f942db 100644
--- 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
diff --git a/lib/sqlalchemy/orm/properties.py b/lib/sqlalchemy/orm/properties.py
index 6be563393..f0ec8f556 100644
--- a/lib/sqlalchemy/orm/properties.py
+++ b/lib/sqlalchemy/orm/properties.py
@@ -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()
diff --git a/test/orm/objectstore.py b/test/orm/objectstore.py
index e897d84a8..18c64e936 100644
--- a/test/orm/objectstore.py
+++ b/test/orm/objectstore.py
@@ -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)