Computed statements containing newlines cause warnings on autogenerate #1391
Labels
autogenerate - detection
use case
not quite a feature and not quite a bug, something we just didn't think of
Describe the bug
When using ORM code that contains multi-line computed statements, they always generate warnings when being fed into Alembic. Like this:
Alembic will always complain with "UserWarning: Computed default on MyModel.start_holding cannot be modified".
Expected behavior
No warning should appear as long as the expression does not change.
To Reproduce
Please try to provide a Minimal, Complete, and Verifiable example, with the migration script and/or the SQLAlchemy tables or models involved.
See also Reporting Bugs on the website.
This is the model:
The reproduction does not work with sqlite, since it stores the SQL expressions verbatim, but the warning does appear for MySQL. Start a MySQL container:
Then initialize alembic and create a first revision:
Set the correct URL in the alembic.ini file:
sqlalchemy.url = mysql+pymysql://root:@localhost:1234/mysql
Set the correct metadata in
env.py
:Generate a first revision and upgrade the database:
Now, when generating additional revisions, a warning will appear:
Error
Versions.
Additional context
Phew, that was a lot of work to write for a two-line PR!
Have a nice day!
The text was updated successfully, but these errors were encountered: