Support Django 5.0 db_default attribute.
A DB default is not considered backward incompatible, as the default value is kept on DB-level. See https://docs.djangoproject.com/en/dev/releases/5.0/#database-computed-default-values
This commit is contained in:
1 parent
3a557cbd7c
commit
18a39cb3fc
12 files changed
+127
-13
No files matched your search
@@ -2,7 +2,9 @@ from __future__ import annotations
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from unittest import skipIf
|
||||
|
||||
import django
|
||||
from django.conf import settings
|
||||
from django.core.management import call_command
|
||||
|
||||
@@ -88,6 +90,11 @@ class BaseBackwardCompatibilityDetection:
|
||||
app = fixtures.ADD_NOT_NULL_COLUMN_FOLLOWED_BY_DEFAULT
|
||||
self._test_linter_finds_no_errors(app)
|
||||
|
||||
@skipIf(django.VERSION[0] < 5, "db_default was implemented in Django 5.0")
|
||||
def test_accept_not_null_column_followed_by_adding_db_default(self):
|
||||
app = fixtures.ADD_NOT_NULL_COLUMN_FOLLOWED_BY_DB_DEFAULT
|
||||
self._test_linter_finds_no_errors(app)
|
||||
|
||||
def test_detect_alter_column(self):
|
||||
app = fixtures.ALTER_COLUMN
|
||||
self._test_linter_finds_no_errors(app)
|
||||
@@ -128,6 +135,11 @@ class SqliteBackwardCompatibilityDetectionTestCase(
|
||||
app = fixtures.MAKE_NOT_NULL_WITH_DJANGO_DEFAULT
|
||||
self._test_linter_finds_errors(app)
|
||||
|
||||
@skipIf(django.VERSION[0] < 5, "db_default was implemented in Django 5.0")
|
||||
def test_accept_not_null_column_followed_by_adding_db_default(self):
|
||||
app = fixtures.ADD_NOT_NULL_COLUMN_FOLLOWED_BY_DB_DEFAULT
|
||||
self._test_linter_finds_errors(app)
|
||||
|
||||
def test_detect_make_column_not_null_with_lib_default(self):
|
||||
# The 'django-add-default-value' doesn't handle sqlite correctly
|
||||
app = fixtures.MAKE_NOT_NULL_WITH_LIB_DEFAULT
|
||||
|
||||
Reference in new issue
Block a user