diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-03-29 21:21:10 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-03-29 21:21:10 +0000 |
| commit | d0f67e2c4de4b688409c2589018fdfdba65e837f (patch) | |
| tree | 1c2b6866e03f69232c33eb5b5eba50c057b2c13c | |
| parent | 290ff9930a33a5c165d3952a7bd1ed858b7a4572 (diff) | |
| download | sqlalchemy-d0f67e2c4de4b688409c2589018fdfdba65e837f.tar.gz | |
- Lazy loader will not use get() if the "lazy load"
SQL clause matches the clause used by get(), but
contains some parameters hardcoded. Previously
the lazy strategy would fail with the get(). Ideally
get() would be used with the hardcoded parameters
but this would require further development.
[ticket:1357]
| -rw-r--r-- | CHANGES | 8 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/expression.py | 2 | ||||
| -rw-r--r-- | test/orm/lazy_relations.py | 21 | ||||
| -rw-r--r-- | test/sql/select.py | 1 |
4 files changed, 31 insertions, 1 deletions
@@ -13,6 +13,14 @@ CHANGES Set collection is now compatible with merge(), fixes [ticket:1352]. + - Lazy loader will not use get() if the "lazy load" + SQL clause matches the clause used by get(), but + contains some parameters hardcoded. Previously + the lazy strategy would fail with the get(). Ideally + get() would be used with the hardcoded parameters + but this would require further development. + [ticket:1357] + - sql - Fixed __repr__() and other _get_colspec() methods on ForeignKey constructed from __clause_element__() style diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index f94e849e5..5a0d5b043 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -2013,7 +2013,7 @@ class _BindParamClause(ColumnElement): the same type. """ - return isinstance(other, _BindParamClause) and other.type.__class__ == self.type.__class__ + return isinstance(other, _BindParamClause) and other.type.__class__ == self.type.__class__ and self.value == other.value def __getstate__(self): """execute a deferred value for serialization purposes.""" diff --git a/test/orm/lazy_relations.py b/test/orm/lazy_relations.py index 4ac8a13ef..b5c3b3669 100644 --- a/test/orm/lazy_relations.py +++ b/test/orm/lazy_relations.py @@ -174,6 +174,27 @@ class LazyTest(_fixtures.FixtureTest): assert [User(id=7, address=Address(id=1))] == l @testing.resolve_artifact_names + def test_many_to_one_binds(self): + mapper(Address, addresses, primary_key=[addresses.c.user_id, addresses.c.email_address]) + + mapper(User, users, properties = dict( + address = relation(Address, uselist=False, + primaryjoin=sa.and_(users.c.id==addresses.c.user_id, addresses.c.email_address=='ed@bettyboop.com') + ) + )) + q = create_session().query(User) + eq_( + [ + User(id=7, address=None), + User(id=8, address=Address(id=3)), + User(id=9, address=None), + User(id=10, address=None), + ], + list(q) + ) + + + @testing.resolve_artifact_names def test_double(self): """tests lazy loading with two relations simulatneously, from the same table, using aliases. """ diff --git a/test/sql/select.py b/test/sql/select.py index 5d6d6dcaa..15c47a674 100644 --- a/test/sql/select.py +++ b/test/sql/select.py @@ -404,6 +404,7 @@ sq.myothertable_othername AS sq_myothertable_othername FROM (" + sqstring + ") A "myothertable.othername = :othername_2 OR myothertable.otherid = :otherid_1) AND sysdate() = today()", checkparams = {'othername_1': 'asdf', 'othername_2':'foo', 'otherid_1': 9, 'myid_1': 12} ) + def test_distinct(self): self.assert_compile( |
