[Sqlalchemy-tickets] Issue #3018: Bad parameter conversion on execute when it is list with one elem
Brought to you by:
zzzeek
|
From: maxdamage <iss...@bi...> - 2014-04-09 15:04:50
|
New issue 3018: Bad parameter conversion on execute when it is list with one element https://bitbucket.org/zzzeek/sqlalchemy/issue/3018/bad-parameter-conversion-on-execute-when maxdamage: ``` #!python some_list = [1, ] # list with one element query = "SELECT * FROM some_table WHERE id IN :param_list " params = { "param_list": some_list } result = db_session.execute(expression.text(query), params) ``` query will look like: ``` #!sql SELECT * FROM some_table WHERE id IN ('1',) ``` When we want to pass list as a parameter to query, and the list has one element there is added coma at the end that breaks the query. When list has more elements there is no additional coma at the end so the query is fine. Tested on 0.7.4. Didn't check newer versions. |