Description
Describe the bug
In our MS SQL Server database we have a default constraint which is (getdate())
for a column. For some reason flask db migrate
was detecting a change even though our server_default
value in our SQLAlchemy model was also (getdate())
. I inspected it with pdb.set_trace() and found that compare_server_default
is converting (getdate())
to getdate(
.
It looks like this commit introduced the bug. In particular, there are slightly different regular expressions being used to clean inspector_column
and metadata_column
, which is why the comparison for this particular string was false.
Expected behavior
compare_server_default
should clean the expression appropriately for both the metadata and inspector defaults, and compare
the cleaned values with each other.
To Reproduce
- Create a model with one datetime column with
server_default
=(getdate())
- Create a corresponding table with the same column and the same default constraint
- Run
flask db migrate
. You should not see any difference in schema, but since the comparison fails there will be a migration script created.
Versions.
- OS: Windows Server 2019
- Python: 3.8
- Alembic: 1.9.1
- SQLAlchemy: 1.4.39
- Database: SQL Server 2019
- DBAPI: