Fix #250 -- Don't consider partial index creation as making a column not nullable.
This commit is contained in:
1 parent
b6acc1dd22
commit
97a1f5c6c9
3 files changed
+16
-1
No files matched your search
@@ -4,8 +4,18 @@
|
|||||||
Instead, the linter crashes and lets the `sqlmigrate` error raise, in order to avoid letting a problematic migration pass.
|
Instead, the linter crashes and lets the `sqlmigrate` error raise, in order to avoid letting a problematic migration pass.
|
||||||
One common reason for such an error is the SQL generation which requires the database to be actually migrated in order to fetch actual constraint names from it.
|
One common reason for such an error is the SQL generation which requires the database to be actually migrated in order to fetch actual constraint names from it.
|
||||||
The crash is a sign to double-check the migration. But if you are certain the migration is safe, you can ignore it (issue #209)
|
The crash is a sign to double-check the migration. But if you are certain the migration is safe, you can ignore it (issue #209)
|
||||||
|
|
||||||
|
Features:
|
||||||
|
|
||||||
- Fixed `RunPython` model import check when using a `through` object like `MyModel.many_to_many.through.objects.filter(...)` (issue #218)
|
- Fixed `RunPython` model import check when using a `through` object like `MyModel.many_to_many.through.objects.filter(...)` (issue #218)
|
||||||
- Mark the `IgnoreMigration` operation as `elidable=True`
|
- Mark the `IgnoreMigration` operation as `elidable=True`
|
||||||
|
|
||||||
|
Bug:
|
||||||
|
|
||||||
|
- Don't detect not nullable field on partial index creation (issue #250)
|
||||||
|
|
||||||
|
Miscellaneous:
|
||||||
|
|
||||||
- Add support for Python 3.11
|
- Add support for Python 3.11
|
||||||
- Add support for Django 4.1
|
- Add support for Django 4.1
|
||||||
- Add support for Django 4.2
|
- Add support for Django 4.2
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ def has_not_null_column(sql_statements: list[str], **kwargs) -> bool:
|
|||||||
ends_with_default = False
|
ends_with_default = False
|
||||||
return (
|
return (
|
||||||
any(
|
any(
|
||||||
re.search("(?<!DROP )NOT NULL", sql) and not sql.startswith("CREATE TABLE")
|
re.search("(?<!DROP )NOT NULL", sql)
|
||||||
|
and not (sql.startswith("CREATE TABLE") or sql.startswith("CREATE INDEX"))
|
||||||
for sql in sql_statements
|
for sql in sql_statements
|
||||||
)
|
)
|
||||||
and ends_with_default is False
|
and ends_with_default is False
|
||||||
|
|||||||
@@ -297,6 +297,10 @@ class PostgresqlAnalyserTestCase(SqlAnalyserTestCase):
|
|||||||
sql = "CREATE UNIQUE INDEX CONCURRENTLY title_idx ON films (title);"
|
sql = "CREATE UNIQUE INDEX CONCURRENTLY title_idx ON films (title);"
|
||||||
self.assertValidSql(sql)
|
self.assertValidSql(sql)
|
||||||
|
|
||||||
|
def test_create_index_concurrently_where(self):
|
||||||
|
sql = 'CREATE INDEX CONCURRENTLY "index_name" ON "table_name" ("a_column") WHERE ("some_column" IS NOT NULL);'
|
||||||
|
self.assertValidSql(sql)
|
||||||
|
|
||||||
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