diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-12-06 22:23:10 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-12-06 22:23:10 +0000 |
| commit | 541b6772e9b8a09b10bd7a16fa9e2b7f693d1194 (patch) | |
| tree | 5dc22ca324eafbb6ac48a296f02f166984252d46 /test/sql/query.py | |
| parent | 3ac9c93e260aa1a5d9c88a648bf7d1213a0e817f (diff) | |
| download | sqlalchemy-541b6772e9b8a09b10bd7a16fa9e2b7f693d1194.tar.gz | |
- generation of "unique" bind parameters has been simplified to use the same
"unique identifier" mechanisms as everything else. This doesn't affect
user code, except any code that might have been hardcoded against the generated
names. Generated bind params now have the form "<paramname>_<num>",
whereas before only the second bind of the same name would have this form.
- bindparam() objects themselves can be used as keys for execute(), i.e.
statement.execute({bind1:'foo', bind2:'bar'})
Diffstat (limited to 'test/sql/query.py')
| -rw-r--r-- | test/sql/query.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/sql/query.py b/test/sql/query.py index 9b35cff1c..6233de743 100644 --- a/test/sql/query.py +++ b/test/sql/query.py @@ -174,6 +174,25 @@ class QueryTest(PersistTest): r = s.execute(userid='fred').fetchall() assert len(r) == 1 + def test_unique_conflict(self): + u = bindparam('userid', unique=True) + s = users.select(or_(users.c.user_name==u, users.c.user_name==u)) + try: + str(s) + assert False + except exceptions.CompileError, e: + assert str(e) == "Bind parameter '{ANON %d userid}' conflicts with unique bind parameter of the same name" % id(u) + + def test_bindparams_in_params(self): + """test that a _BindParamClause itself can be a key in the params dict""" + + users.insert().execute(user_id = 7, user_name = 'jack') + users.insert().execute(user_id = 8, user_name = 'fred') + + u = bindparam('userid') + r = users.select(users.c.user_name==u).execute({u:'fred'}).fetchall() + assert len(r) == 1 + def test_bindparam_shortname(self): """test the 'shortname' field on BindParamClause.""" users.insert().execute(user_id = 7, user_name = 'jack') |
