summaryrefslogtreecommitdiff
path: root/alembic/ddl/mssql.py
diff options
context:
space:
mode:
Diffstat (limited to 'alembic/ddl/mssql.py')
-rw-r--r--alembic/ddl/mssql.py30
1 files changed, 20 insertions, 10 deletions
diff --git a/alembic/ddl/mssql.py b/alembic/ddl/mssql.py
index 6a208ec..00c5f0e 100644
--- a/alembic/ddl/mssql.py
+++ b/alembic/ddl/mssql.py
@@ -1,5 +1,6 @@
from __future__ import annotations
+import re
from typing import Any
from typing import List
from typing import Optional
@@ -230,16 +231,25 @@ class MSSQLImpl(DefaultImpl):
rendered_metadata_default,
rendered_inspector_default,
):
- def clean(value):
- if value is not None:
- value = value.strip()
- while value[0] == "(" and value[-1] == ")":
- value = value[1:-1]
- return value
-
- return clean(rendered_inspector_default) != clean(
- rendered_metadata_default
- )
+ if rendered_metadata_default is not None:
+ rendered_metadata_default = re.sub(
+ r"^\((.+)\)$", r"\1", rendered_metadata_default
+ )
+
+ rendered_metadata_default = re.sub(
+ r"^\"?'(.+)'\"?$", r"\1", rendered_metadata_default
+ )
+
+ if rendered_inspector_default is not None:
+ rendered_inspector_default = re.sub(
+ r"^\(+(.+?)\)+$", r"\1", rendered_inspector_default
+ )
+
+ rendered_inspector_default = re.sub(
+ r"^\"?'(.+)'\"?$", r"\1", rendered_inspector_default
+ )
+
+ return rendered_inspector_default != rendered_metadata_default
def _compare_identity_default(self, metadata_identity, inspector_identity):
diff, ignored, is_alter = super()._compare_identity_default(