skip to Main Content

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


  1. Chosen as BEST ANSWER

    Workaround and patch to SQLAlchemy here: https://github.com/sqlalchemy/sqlalchemy/discussions/9585


  2. Try setting quote=True on the row_number column: https://docs.sqlalchemy.org/en/20/core/metadata.html#sqlalchemy.schema.Column.params.quote

    This should cause the column to be quoted automatically.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search