From: Mike Bayer Date: Tue, 20 Oct 2009 16:19:54 +0000 (+0000) Subject: merged r6416 of 0.5 branch, fix the "numeric" paramstyle and add tests X-Git-Tag: rel_0_6beta1~239 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b457b973102c8fe7c3105d5984f48a3265a5168;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git merged r6416 of 0.5 branch, fix the "numeric" paramstyle and add tests --- diff --git a/CHANGES b/CHANGES index 4de7b2e22f..850dcf8dbd 100644 --- a/CHANGES +++ b/CHANGES @@ -580,6 +580,16 @@ 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. + This is postgresql.DOUBLE_PRECISION in 0.6. + [ticket:1085] + - mssql - Changed the name of TrustedConnection to Trusted_Connection when constructing pyodbc connect diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 59034ca227..f07e6aca8c 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -56,7 +56,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 554938dc85..757dc52136 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", Integer)], 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') + ) + def test_nested_uselabels(self): """test nested anonymous label generation. this