diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2022-05-25 16:45:49 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2022-05-25 16:45:49 +0000 |
| commit | 9d5ae6b9f642d0c2f7843a866019e6733afc2767 (patch) | |
| tree | a2b32c362381de1eae530222303d4ade3ca43332 /test/sql/test_compiler.py | |
| parent | 17deb79902f3f9ff498ecdc9792156839c4b9923 (diff) | |
| parent | 853d6be759ad79d0d3e1d6a52fc7c9c32c0146ec (diff) | |
| download | sqlalchemy-9d5ae6b9f642d0c2f7843a866019e6733afc2767.tar.gz | |
Merge "apply bindparam escape name to processors dictionary" into rel_1_4
Diffstat (limited to 'test/sql/test_compiler.py')
| -rw-r--r-- | test/sql/test_compiler.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index 33f84142b..99addb986 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -25,6 +25,7 @@ from sqlalchemy import Column from sqlalchemy import Date from sqlalchemy import desc from sqlalchemy import distinct +from sqlalchemy import Enum from sqlalchemy import exc from sqlalchemy import except_ from sqlalchemy import exists @@ -96,6 +97,7 @@ from sqlalchemy.testing import is_ from sqlalchemy.testing import is_true from sqlalchemy.testing import mock from sqlalchemy.testing import ne_ +from sqlalchemy.testing.schema import pep435_enum from sqlalchemy.util import u table1 = table( @@ -3655,6 +3657,46 @@ class BindParameterTest(AssertsCompiledSQL, fixtures.TestBase): s, ) + def test_bind_param_escaping(self): + """general bind param escape unit tests added as a result of + #8053 + # + #""" + + SomeEnum = pep435_enum("SomeEnum") + one = SomeEnum("one", 1) + SomeEnum("two", 2) + + t = Table( + "t", + MetaData(), + Column("_id", Integer, primary_key=True), + Column("_data", Enum(SomeEnum)), + ) + + class MyCompiler(compiler.SQLCompiler): + def bindparam_string(self, name, **kw): + kw["escaped_from"] = name + return super(MyCompiler, self).bindparam_string( + '"%s"' % name, **kw + ) + + dialect = default.DefaultDialect() + dialect.statement_compiler = MyCompiler + + self.assert_compile( + t.insert(), + 'INSERT INTO t (_id, _data) VALUES (:"_id", :"_data")', + dialect=dialect, + ) + + compiled = t.insert().compile( + dialect=dialect, compile_kwargs=dict(compile_keys=("_id", "_data")) + ) + params = compiled.construct_params({"_id": 1, "_data": one}) + eq_(params, {'"_id"': 1, '"_data"': one}) + eq_(compiled._bind_processors, {'"_data"': mock.ANY}) + def test_expanding_non_expanding_conflict(self): """test #8018""" |
