- changed status to wontfix
query.filter(cond).filter_by() produces invalid SQL
Issue #1423
resolved
session.filter(some_cond).filter_by(**kwargs).first() produces broken SQL when kwargs is empty dictionary: ... WHERE <some_cond> AND ORDER BY ...
Here is error message from my real-life project:
ProgrammingError: (ProgrammingError) (1064, "You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY
`Doc`.date DESC \n LIMIT 0, 1' at line 3") u'SELECT `Doc`.id AS `Doc_id`, `Doc`.type AS
`Doc_type`, `Doc`.date AS `Doc_date`, `Doc`.state AS `Doc_state`, `Doc`.place AS `Doc_place`,
`Doc`.title AS `Doc_title` \nFROM `Doc` \nWHERE `Doc`.state = %s AND ORDER BY `Doc`.date DESC
\n LIMIT 0, 1' [4](4)
Using SQLAlchemy 0.5.4p1. This is probably related to the ticket #1011.
Comments (1)
-
repo owner - Log in to comment
test added in a7d0ed81bd77c3721ef2afba8774c50fd34ec78f