[Sqlalchemy-tickets] Issue #4371: SQLAlchemy fails to ignores parameters that are inside of SQL Tex
Brought to you by:
zzzeek
From: cowbert <iss...@bi...> - 2018-11-21 02:35:02
|
New issue 4371: SQLAlchemy fails to ignores parameters that are inside of SQL Text comments in SQLAlchemy 1.2+? https://bitbucket.org/zzzeek/sqlalchemy/issues/4371/sqlalchemy-fails-to-ignores-parameters cowbert: Given a SQL textstring of: ``` #!python s = sqlalchemy.sql.text("""With t as ( SELECT 'value1' v from dual union select 'value2' v from dual) --, comment_cte as ("select 1 from dual") select * from t --where t = :param_t """) ``` In earlier versions of SQLAlchemy (1.1) and cx_Oracle (5.x), this can be executed by SQLAlchemy core with: engine.connect().execute(s) In SQLAlchemy 1.2+ and cxOracle 7, this will return an error reference to: http://sqlalche.me/e/cd3x SQLAlchemy properly ignores comments otherwise (for example, deleting the line `--where t = :param_t` will execute properly.) Changing `--` style comments to the `/* */` style results in the same error. Env: Python 3.6.4, SQLAlchemy 1.2.14, cx-Oracle 7.0.0 Full stack trace: ``` #!python Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1127, in _execute_context context = constructor(dialect, self, conn, *args) File "/usr/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 631, in _init_compiled self.compiled_parameters = [compiled.construct_params()] File "/usr/lib/python3.6/site-packages/sqlalchemy/sql/compiler.py", line 566, in construct_params % bindparam.key, code="cd3x") sqlalchemy.exc.InvalidRequestError: A value is required for bind parameter 'param_t' (Background on this error at: http://sqlalche.me/e/cd3x) ``` |