diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-11-28 11:10:41 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-11-28 11:10:41 -0500 |
| commit | 52167e1c37a6d704f01dc15bcb14ec2489979457 (patch) | |
| tree | 5752aec7ba3e2abb2cad53045bad45c516eefdb0 /lib | |
| parent | 20418096d5862ed40f22b6c7b7cc53dd212bbd21 (diff) | |
| download | sqlalchemy-52167e1c37a6d704f01dc15bcb14ec2489979457.tar.gz | |
- Query.get() will raise if the number of params
in a composite key is too large, as well as too
small. [ticket:1977]
- the above change smoked out an old mistake in a unit test.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sqlalchemy/orm/query.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index 2bccb8f73..ef75efd76 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -1919,6 +1919,12 @@ class Query(object): q = self._clone() if ident is not None: + if len(ident) != len(mapper.primary_key): + raise sa_exc.InvalidRequestError( + "Incorrect number of values in identifier to formulate " + "primary key for query.get(); primary key columns are %s" % + ','.join("'%s'" % c for c in mapper.primary_key)) + (_get_clause, _get_params) = mapper._get_clause # None present in ident - turn those comparisons @@ -1939,12 +1945,6 @@ class Query(object): for id_val, primary_key in zip(ident, mapper.primary_key) ]) - if len(params) != len(mapper.primary_key): - raise sa_exc.InvalidRequestError( - "Incorrect number of values in identifier to formulate " - "primary key for query.get(); primary key columns are %s" % - ','.join("'%s'" % c for c in mapper.primary_key)) - q._params = params if lockmode is not None: |
