diff options
| author | Jason Kirtland <jek@discorporate.us> | 2007-08-09 22:10:16 +0000 |
|---|---|---|
| committer | Jason Kirtland <jek@discorporate.us> | 2007-08-09 22:10:16 +0000 |
| commit | ce0d72e68aac6ad6c7569ffe76ca5c6c02d2718c (patch) | |
| tree | 0b06377f98ec2872e19cfb7a81a27965b696bb2b /test/sql/query.py | |
| parent | 491cbf97a4e700fde69e4dfe73479173fc871c63 (diff) | |
| download | sqlalchemy-ce0d72e68aac6ad6c7569ffe76ca5c6c02d2718c.tar.gz | |
Allow '$' in bind param detection [ticket:719], added test suite & fixed an edge case
Diffstat (limited to 'test/sql/query.py')
| -rw-r--r-- | test/sql/query.py | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/test/sql/query.py b/test/sql/query.py index 48a28a9a5..4f569f1c0 100644 --- a/test/sql/query.py +++ b/test/sql/query.py @@ -1,7 +1,7 @@ import testbase import datetime from sqlalchemy import * -from sqlalchemy import exceptions +from sqlalchemy import exceptions, ansisql from testlib import * @@ -164,6 +164,37 @@ class QueryTest(PersistTest): s = users.select(users.c.user_name==u) r = s.execute(someshortname='fred').fetchall() assert len(r) == 1 + + def test_bindparam_detection(self): + dialect = ansisql.ANSIDialect(default_paramstyle='qmark') + prep = lambda q: dialect.compile(sql.text(q)).string + + def a_eq(got, wanted): + if got != wanted: + print "Wanted %s" % wanted + print "Received %s" % got + self.assert_(got == wanted) + + a_eq(prep('select foo'), 'select foo') + a_eq(prep("time='12:30:00'"), "time='12:30:00'") + a_eq(prep(u"time='12:30:00'"), u"time='12:30:00'") + a_eq(prep(":this:that"), ":this:that") + a_eq(prep(":this :that"), "? ?") + a_eq(prep("(:this),(:that :other)"), "(?),(? ?)") + a_eq(prep("(:this),(:that:other)"), "(?),(:that:other)") + a_eq(prep("(:this),(:that,:other)"), "(?),(?,?)") + a_eq(prep("(:that_:other)"), "(:that_:other)") + a_eq(prep("(:that_ :other)"), "(? ?)") + a_eq(prep("(:that_other)"), "(?)") + a_eq(prep("(:that$other)"), "(?)") + a_eq(prep("(:that$:other)"), "(:that$:other)") + a_eq(prep(".:that$ :other."), ".? ?.") + + a_eq(prep(r'select \foo'), r'select \foo') + a_eq(prep(r"time='12\:30:00'"), r"time='12\:30:00'") + a_eq(prep(":this \:that"), "? :that") + a_eq(prep(r"(\:that$other)"), "(:that$other)") + a_eq(prep(r".\:that$ :other."), ".:that$ ?.") def testdelete(self): users.insert().execute(user_id = 7, user_name = 'jack') |
