Don't consider partial unique index creation as making a column not nullable.
This commit is contained in:
1 parent
b15924ca0f
commit
a230681de5
3 files changed
+8
-1
No files matched your search
@@ -6,6 +6,7 @@ Feature:
|
|||||||
|
|
||||||
Bug:
|
Bug:
|
||||||
- Don't detect 'IS NOT NULL' as backward incompatible changes (issue #263)
|
- Don't detect 'IS NOT NULL' as backward incompatible changes (issue #263)
|
||||||
|
- Don't consider UNIQUE INDEX creation as making a column not nullable
|
||||||
|
|
||||||
Miscellaneous:
|
Miscellaneous:
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,9 @@ def has_not_null_column(sql_statements: list[str], **kwargs) -> bool:
|
|||||||
|
|
||||||
for sql in sql_statements:
|
for sql in sql_statements:
|
||||||
if re.search("(?<!DROP )(?<!IS )NOT NULL", sql) and not (
|
if re.search("(?<!DROP )(?<!IS )NOT NULL", sql) and not (
|
||||||
sql.startswith("CREATE TABLE") or sql.startswith("CREATE INDEX")
|
sql.startswith("CREATE TABLE")
|
||||||
|
or sql.startswith("CREATE INDEX")
|
||||||
|
or sql.startswith("CREATE UNIQUE INDEX")
|
||||||
):
|
):
|
||||||
not_null_column = True
|
not_null_column = True
|
||||||
if re.search("DEFAULT.*NOT NULL", sql):
|
if re.search("DEFAULT.*NOT NULL", sql):
|
||||||
|
|||||||
@@ -336,6 +336,10 @@ class PostgresqlAnalyserTestCase(SqlAnalyserTestCase):
|
|||||||
sql = 'CREATE INDEX CONCURRENTLY "index_name" ON "table_name" ("a_column") WHERE ("some_column" IS NOT NULL);'
|
sql = 'CREATE INDEX CONCURRENTLY "index_name" ON "table_name" ("a_column") WHERE ("some_column" IS NOT NULL);'
|
||||||
self.assertValidSql(sql)
|
self.assertValidSql(sql)
|
||||||
|
|
||||||
|
def test_create_unique_index_concurrently_where(self):
|
||||||
|
sql = 'CREATE UNIQUE INDEX CONCURRENTLY "index_name" ON "table_name" ("a_column") WHERE ("some_column" IS NOT NULL);'
|
||||||
|
self.assertBackwardIncompatibleSql(sql, "ADD_UNIQUE")
|
||||||
|
|
||||||
def test_drop_index_non_concurrently(self):
|
def test_drop_index_non_concurrently(self):
|
||||||
sql = "DROP INDEX ON films"
|
sql = "DROP INDEX ON films"
|
||||||
self.assertWarningSql(sql)
|
self.assertWarningSql(sql)
|
||||||
|
|||||||
Reference in new issue
Block a user