summaryrefslogtreecommitdiff
path: root/test/dialect/oracle/test_compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-09-04 18:46:53 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2019-09-05 09:53:37 -0400
commitd7aa017d83b416187b54ad38400475fd86d80671 (patch)
tree61e864530882f36733c12dadcb135af5a9d7d676 /test/dialect/oracle/test_compiler.py
parentc3dcdbd21de44b23e527f5580c318e47ea6930a7 (diff)
downloadsqlalchemy-d7aa017d83b416187b54ad38400475fd86d80671.tar.gz
Strip special chars in anonymized bind names
Characters that interfere with "pyformat" or "named" formats in bound parameters, namely ``%, (, )`` and the space character, as well as a few other typically undesirable characters, are stripped early for a :func:`.bindparam` that is using an anonymized name, which is typically generated automatically from a named column which itself includes these characters in its name and does not use a ``.key``, so that they do not interfere either with the SQLAlchemy compiler's use of string formatting or with the driver-level parsing of the parameter, both of which could be demonstrated before the fix. The change only applies to anonymized parameter names that are generated and consumed internally, not end-user defined names, so the change should have no impact on any existing code. Applies in particular to the psycopg2 driver which does not otherwise quote special parameter names, but also strips leading underscores to suit Oracle (but not yet leading numbers, as some anon parameters are currently entirely numeric/underscore based); Oracle in any case continues to quote parameter names that include special characters. Fixes: #4837 Change-Id: I21cb654c3e4ef786114160b8b4295242720bf3f9
Diffstat (limited to 'test/dialect/oracle/test_compiler.py')
-rw-r--r--test/dialect/oracle/test_compiler.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/test/dialect/oracle/test_compiler.py b/test/dialect/oracle/test_compiler.py
index 2edb68e88..a6ea7d2b1 100644
--- a/test/dialect/oracle/test_compiler.py
+++ b/test/dialect/oracle/test_compiler.py
@@ -177,14 +177,14 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
self.assert_compile(
s,
"SELECT anon_1.col1, anon_1.col2 FROM "
- "(SELECT /*+ FIRST_ROWS([POSTCOMPILE__ora_frow_1]) */ "
+ "(SELECT /*+ FIRST_ROWS([POSTCOMPILE_ora_frow_1]) */ "
"anon_2.col1 AS col1, "
"anon_2.col2 AS col2, ROWNUM AS ora_rn FROM (SELECT "
"sometable.col1 AS col1, sometable.col2 AS "
"col2 FROM sometable) anon_2 WHERE ROWNUM <= "
"[POSTCOMPILE_param_1]) anon_1 WHERE ora_rn > "
"[POSTCOMPILE_param_2]",
- checkparams={"_ora_frow_1": 10, "param_1": 30, "param_2": 20},
+ checkparams={"ora_frow_1": 10, "param_1": 30, "param_2": 20},
dialect=oracle.OracleDialect(optimize_limits=True),
)
@@ -263,13 +263,13 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
s = select([t]).with_for_update().limit(10).order_by(t.c.col2)
self.assert_compile(
s,
- "SELECT /*+ FIRST_ROWS([POSTCOMPILE__ora_frow_1]) */ "
+ "SELECT /*+ FIRST_ROWS([POSTCOMPILE_ora_frow_1]) */ "
"anon_1.col1, anon_1.col2 FROM (SELECT "
"sometable.col1 AS col1, sometable.col2 AS "
"col2 FROM sometable ORDER BY "
"sometable.col2) anon_1 WHERE ROWNUM <= [POSTCOMPILE_param_1] "
"FOR UPDATE",
- checkparams={"param_1": 10, "_ora_frow_1": 10},
+ checkparams={"param_1": 10, "ora_frow_1": 10},
dialect=oracle.OracleDialect(optimize_limits=True),
)