From: Mike Bayer Date: Tue, 20 Oct 2009 16:17:48 +0000 (+0000) Subject: - Fixed the "numeric" paramstyle, which apparently is the X-Git-Tag: rel_0_5_7~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec11fc289cfc565957918069a09558d7f4ffcbd9;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Fixed the "numeric" paramstyle, which apparently is the default paramstyle used by Informixdb. --- diff --git a/CHANGES b/CHANGES index 4ecb2552ea..231f97828f 100644 --- a/CHANGES +++ b/CHANGES @@ -23,6 +23,10 @@ CHANGES by contains_eager() out of individual instance states. [ticket:1553] +- sql + - Fixed the "numeric" paramstyle, which apparently is the + default paramstyle used by Informixdb. + - postgresql - Added support for reflecting the DOUBLE PRECISION type, via a new postgres.PGDoublePrecision object. diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 6af65ec140..9c06d99277 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -52,7 +52,7 @@ BIND_TEMPLATES = { 'pyformat':"%%(%(name)s)s", 'qmark':"?", 'format':"%%s", - 'numeric':"%(position)s", + 'numeric':":%(position)s", 'named':":%(name)s" } diff --git a/test/sql/test_select.py b/test/sql/test_select.py index f70492fb31..941973e5fb 100644 --- a/test/sql/test_select.py +++ b/test/sql/test_select.py @@ -152,6 +152,36 @@ sq.myothertable_othername AS sq_myothertable_othername FROM (" + sqstring + ") A select([cast("data", sqlite.SLInteger)], use_labels=True), # this will work with plain Integer in 0.6 "SELECT CAST(:param_1 AS INTEGER) AS anon_1" ) + + def test_paramstyles(self): + + stmt = text("select :foo, :bar, :bat from sometable") + + self.assert_compile( + stmt, + "select ?, ?, ? from sometable" + , dialect=default.DefaultDialect(paramstyle='qmark') + ) + self.assert_compile( + stmt, + "select :foo, :bar, :bat from sometable" + , dialect=default.DefaultDialect(paramstyle='named') + ) + self.assert_compile( + stmt, + "select %s, %s, %s from sometable" + , dialect=default.DefaultDialect(paramstyle='format') + ) + self.assert_compile( + stmt, + "select :1, :2, :3 from sometable" + , dialect=default.DefaultDialect(paramstyle='numeric') + ) + self.assert_compile( + stmt, + "select %(foo)s, %(bar)s, %(bat)s from sometable" + , dialect=default.DefaultDialect(paramstyle='pyformat') + )