From: Mike Bayer Date: Mon, 10 Nov 2014 23:02:14 +0000 (-0500) Subject: - we aren't changing .key behavior yet here, this is just documentation X-Git-Tag: rel_0_9_9~76 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c5d2f0999b15979a7251eb305127da1c53cbff55;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - we aren't changing .key behavior yet here, this is just documentation --- diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg2.py b/lib/sqlalchemy/dialects/postgresql/psycopg2.py index f67b2e3b05..4df30a7063 100644 --- a/lib/sqlalchemy/dialects/postgresql/psycopg2.py +++ b/lib/sqlalchemy/dialects/postgresql/psycopg2.py @@ -169,25 +169,9 @@ actually contain percent or parenthesis symbols; as SQLAlchemy in many cases generates bound parameter names based on the name of a column, the presence of these characters in a column name can lead to problems. -There are two solutions to the issue of a :class:`.schema.Column` that contains -one of these characters in its name. One is to specify the -:paramref:`.schema.Column.key` for columns that have such names:: - - measurement = Table('measurement', metadata, - Column('Size (meters)', Integer, key='size_meters') - ) - -Above, an INSERT statement such as ``measurement.insert()`` will use -``size_meters`` as the parameter name, and a SQL expression such as -``measurement.c.size_meters > 10`` will derive the bound parameter name -from the ``size_meters`` key as well. - -.. versionchanged:: 1.0.0 - SQL expressions will use :attr:`.Column.key` - as the source of naming when anonymous bound parameters are created - in SQL expressions; previously, this behavior only applied to - :meth:`.Table.insert` and :meth:`.Table.update` parameter names. - -The other solution is to use a positional format; psycopg2 allows use of the +The best solution in SQLAlchemy 0.9 and earlier to the issue of a +:class:`.schema.Column` that contains one of these characters in its +name is to use a positional format for the engine; psycopg2 allows use of the "format" paramstyle, which can be passed to :paramref:`.create_engine.paramstyle`:: @@ -207,6 +191,9 @@ we instead see:: Where above, the dictionary style is converted into a tuple with positional style. +SQLAlchemy 1.0 will also allow the per-column :attr:`.Column.key` setting to +be usable in producing an appropriate parameter name. + Transactions ------------