I have a table that includes an int column named row_number
. This worked fine until I upgraded Debian from 11 to 12 which upgraded MariaDB from 10.5 to 10.11.
I now get errors when using SQLAlchemy.
I’ve tracked down where the error occurs. With 10.11, this statement gives an error:
UPDATE kae SET row_number=12 WHERE id=1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘row_number=12 WHERE id=1’ at line 1
If I put backticks around the column name the update runs without error.
Can I force SQLAlchemy to backtick-quote that column name every time?
Is there a better fix than having to edit all occurrences of row_number in my code?
2
Answers
Workaround and patch to SQLAlchemy here: https://github.com/sqlalchemy/sqlalchemy/discussions/9585
Try setting
quote=True
on therow_number
column: https://docs.sqlalchemy.org/en/20/core/metadata.html#sqlalchemy.schema.Column.params.quoteThis should cause the column to be quoted automatically.