summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-09-09 15:51:40 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2011-09-09 15:51:40 -0400
commit1492cc634ee67afb5ad03f0d56caca9fc3bbcc0e (patch)
tree5ca87a8d50adc65bd6971d6843b2fe85420bb7a9 /test
parent07179d2aae12bb4e72eb1e494a870eefada8320a (diff)
downloadsqlalchemy-1492cc634ee67afb5ad03f0d56caca9fc3bbcc0e.tar.gz
- Fixed bug whereby if __eq__() was
redefined, a relationship many-to-one lazyload would hit the __eq__() and fail. [ticket:2260] Does not apply to 0.6.9.
Diffstat (limited to 'test')
-rw-r--r--test/ext/test_sqlsoup.py6
-rw-r--r--test/orm/test_mapper.py22
2 files changed, 28 insertions, 0 deletions
diff --git a/test/ext/test_sqlsoup.py b/test/ext/test_sqlsoup.py
index 88601b5cf..09e7535b2 100644
--- a/test/ext/test_sqlsoup.py
+++ b/test/ext/test_sqlsoup.py
@@ -279,6 +279,12 @@ class SQLSoupTest(fixtures.TestBase):
db.users.relate('loans', db.loans, order_by=db.loans.loan_date,
cascade='all, delete-orphan')
+ def test_relate_m2o(self):
+ db = sqlsoup.SqlSoup(engine)
+ db.loans.relate('user', db.users)
+ u1 = db.users.filter(db.users.c.name=='Joe Student').one()
+ eq_(db.loans.first().user, u1)
+
def test_explicit_session(self):
Session = scoped_session(sessionmaker())
db = sqlsoup.SqlSoup(engine, session=Session)
diff --git a/test/orm/test_mapper.py b/test/orm/test_mapper.py
index ba477e8e6..ce729ed6b 100644
--- a/test/orm/test_mapper.py
+++ b/test/orm/test_mapper.py
@@ -690,6 +690,28 @@ class MapperTest(_fixtures.FixtureTest):
s.add(A())
s.commit()
+ def test_we_dont_call_eq(self):
+ class NoEqAllowed(object):
+ def __eq__(self, other):
+ raise Exception("nope")
+
+ addresses, users = self.tables.addresses, self.tables.users
+ Address = self.classes.Address
+
+ mapper(NoEqAllowed, users, properties={
+ 'addresses':relationship(Address, backref='user')
+ })
+ mapper(Address, addresses)
+
+ u1 = NoEqAllowed()
+ u1.name = "some name"
+ u1.addresses = [Address(id=12, email_address='a1')]
+ s = Session(testing.db)
+ s.add(u1)
+ s.commit()
+
+ a1 = s.query(Address).filter_by(id=12).one()
+ assert a1.user is u1
def test_mapping_to_join_raises(self):
"""Test implicit merging of two cols raises."""