Handle server default quoting

Alembic was previously modifying the metadata server default when
comparing it in the autogenerate process. This was removed in Alembic
1.11. As noted in the commit message [1], we implement our own
'compare_server_default' which means we now need to handle this.

[1] https://github.com/sqlalchemy/alembic/commit/230a2932f6

Change-Id: Ib5f8f78b917d79c4c234cc689c13acff011c2403
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2023-06-14 16:08:47 -07:00
parent bbb5fbe47b
commit c69e5e5f89
1 changed files with 7 additions and 0 deletions

View File

@ -18,6 +18,7 @@ import abc
import functools
import logging
import pprint
import re
import alembic
import alembic.autogenerate
@ -240,6 +241,12 @@ class ModelsMigrationsSync(object, metaclass=abc.ABCMeta):
isinstance(meta_def.arg, expr.False_) and insp_def == "0"
)
if isinstance(meta_col.type, sqlalchemy.String):
if meta_def is None or insp_def is None:
return meta_def != insp_def
insp_def = re.sub(r"^'|'$", "", insp_def)
return meta_def.arg != insp_def
def filter_metadata_diff(self, diff):
"""Filter changes before assert in test_models_sync().