Fix #115 -- Detect correctly if a field ends with a default value or a dropped default
This commit is contained in:
1 parent
f21ff2c278
commit
b3816613d5
1 file changed
+13
-4
@@ -8,10 +8,19 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
def has_not_null_column(sql_statements, **kwargs):
|
def has_not_null_column(sql_statements, **kwargs):
|
||||||
# TODO: improve to detect that the same column is concerned
|
# TODO: improve to detect that the same column is concerned
|
||||||
return any(
|
ends_with_default = None
|
||||||
re.search("(?<!DROP )NOT NULL", sql) and not sql.startswith("CREATE TABLE")
|
for sql in sql_statements:
|
||||||
for sql in sql_statements
|
if "SET DEFAULT" in sql:
|
||||||
) and not any("SET DEFAULT" in sql for sql in sql_statements)
|
ends_with_default = True
|
||||||
|
elif "DROP DEFAULT" in sql:
|
||||||
|
ends_with_default = False
|
||||||
|
return (
|
||||||
|
any(
|
||||||
|
re.search("(?<!DROP )NOT NULL", sql) and not sql.startswith("CREATE TABLE")
|
||||||
|
for sql in sql_statements
|
||||||
|
)
|
||||||
|
and ends_with_default is False
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def has_add_unique(sql_statements, **kwargs):
|
def has_add_unique(sql_statements, **kwargs):
|
||||||
|
|||||||
Reference in new issue
Block a user