Open

Description
Describe the bug
Warning is emitted when generating migration for model with computed column.
Expected behavior
No warning emitted.
To Reproduce
Code
# app.py
import os
import flask
import flask_sqlalchemy as fsa
import flask_migrate as fm
import sqlalchemy as sa
app = flask.Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = (
f'mariadb+pymysql://{os.environ['DB_USER']}:{os.environ['DB_PASSWORD']}'
'@localhost:{os.environ['DB_PORT']}/{os.environ['DB_NAME']}'
)
db = fsa.SQLAlchemy(app)
migrate = fm.Migrate(app, db)
class RecordWithComputed(db.Model):
id = sa.Column(sa.Integer, primary_key=True)
created_at = sa.Column(sa.DateTime, nullable=False)
deleted_at = sa.Column(sa.DateTime)
is_active_record = sa.Column(sa.Boolean, sa.Computed('CASE WHEN deleted_at IS NULL THEN TRUE ELSE NULL END'))
Steps to reproduce
- Create and apply first migration.
- Try creating second migration.
Error
Output for first migration
flask db migrate -m "first migration"
INFO [alembic.runtime.migration] Context impl MariaDBImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.autogenerate.compare] Detected added table 'record_with_computed'
Generating /Users/eganma/junk/computed-column-warning/migrations/versions/15d57df5db98_first_migration.py ... done
Output for second migration (no changes made to app.py)
flask db migrate -m "second migration"
INFO [alembic.runtime.migration] Context impl MariaDBImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
/Users/eganma/Library/Caches/pypoetry/virtualenvs/computed-column-warning-swI5pdsd-py3.12/lib/python3.12/site-packages/alembic/autogenerate/compare.py:1034: UserWarning: Computed default on record_with_computed.is_active_record cannot be modified
util.warn("Computed default on %s.%s cannot be modified" % (tname, cname))
INFO [alembic.env] No changes in schema detected.
Strings being compared at compare.py:1029
rendered_metadata_default = 'casewhendeleted_atisnullthentrueelsenullend'
rendered_conn_default = 'casewhendeleted_atisnullthen1elsenullend'
Versions.
- OS: macOS
- Python: 3.12.0
- Alembic: 1.14.1
- SQLAlchemy: 2.0.38
- Database: MariaDB 10.11.6
- DBAPI: pymysql 1.1.1
Additional context
Doesn't look like this is causing problems for me at this time, but previous reports I found (#1151, #1462) were focused on postgres. Issue seems to stem from TRUE being reported as the boolean equivalent 1 when comparing the model against the schema.