diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-11-10 17:37:26 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-11-10 17:37:26 -0500 |
commit | a19b2f419cd876b561a3b3c21ebed5c223192883 (patch) | |
tree | 333e5880330fa6cc567085967040effa1d6ac418 /test/sql/test_compiler.py | |
parent | 9b1777288ba9f49248485ead0f77597dacf6de2e (diff) | |
download | sqlalchemy-a19b2f419cd876b561a3b3c21ebed5c223192883.tar.gz |
- The :attr:`.Column.key` attribute is now used as the source of
anonymous bound parameter names within expressions, to match the
existing use of this value as the key when rendered in an INSERT
or UPDATE statement. This allows :attr:`.Column.key` to be used
as a "substitute" string to work around a difficult column name
that doesn't translate well into a bound parameter name. Note that
the paramstyle is configurable on :func:`.create_engine` in any case,
and most DBAPIs today support a named and positional style.
fixes #3245
Diffstat (limited to 'test/sql/test_compiler.py')
-rw-r--r-- | test/sql/test_compiler.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index bfafed599..5d1afe616 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -435,6 +435,19 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): dialect=default.DefaultDialect(paramstyle='pyformat') ) + def test_anon_param_name_on_keys(self): + self.assert_compile( + keyed.insert(), + "INSERT INTO keyed (x, y, z) VALUES (%(colx)s, %(coly)s, %(z)s)", + dialect=default.DefaultDialect(paramstyle='pyformat') + ) + self.assert_compile( + keyed.c.coly == 5, + "keyed.y = %(coly_1)s", + checkparams={'coly_1': 5}, + dialect=default.DefaultDialect(paramstyle='pyformat') + ) + def test_dupe_columns(self): """test that deduping is performed against clause element identity, not rendered result.""" |