summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShai Berger <shai@platonix.com>2015-04-18 18:52:30 +0300
committerShai Berger <shai@platonix.com>2015-04-18 19:17:10 +0300
commit773ec512b1872d4090b2ff8a759a85cc0f505bb9 (patch)
treef57d7b66e6a2b5c8a0b39fde815d1a38ebeccf31
parent84142946c0e8dfdda18391e595bd2e53001f2ea6 (diff)
[1.7.x] Fixed #24595 Oracle test failure
The only problem for Oracle was the test, which tested nullity on text/char fields -- but Oracle interprets_empty_strings_as_null. Backport of d5a0acc from master
-rw-r--r--tests/schema/tests.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py
index a0fa8958d7..7b4f751852 100644
--- a/tests/schema/tests.py
+++ b/tests/schema/tests.py
@@ -1,10 +1,10 @@
import datetime
import unittest
-from django.test import TransactionTestCase
+from django.test import TransactionTestCase, skipIfDBFeature
from django.db import connection, DatabaseError, IntegrityError, OperationalError
-from django.db.models.fields import (BinaryField, BooleanField, CharField, IntegerField,
- PositiveIntegerField, SlugField, TextField)
+from django.db.models.fields import (BigIntegerField, BinaryField, BooleanField, CharField,
+ IntegerField, PositiveIntegerField, SlugField, TextField)
from django.db.models.fields.related import ForeignKey, ManyToManyField, OneToOneField
from django.db.transaction import atomic
from .fields import CustomManyToManyField, InheritedManyToManyField
@@ -439,7 +439,8 @@ class SchemaTests(TransactionTestCase):
strict=True,
)
- def test_alter_field_keep_null_status(self):
+ @skipIfDBFeature('interprets_empty_strings_as_nulls')
+ def test_alter_textual_field_keep_null_status(self):
"""
Changing a field type shouldn't affect the not null status.
"""
@@ -455,6 +456,22 @@ class SchemaTests(TransactionTestCase):
with self.assertRaises(IntegrityError):
Note.objects.create(info=None)
+ def test_alter_numeric_field_keep_null_status(self):
+ """
+ Changing a field type shouldn't affect the not null status.
+ """
+ with connection.schema_editor() as editor:
+ editor.create_model(UniqueTest)
+ with self.assertRaises(IntegrityError):
+ UniqueTest.objects.create(year=None, slug='aaa')
+ old_field = UniqueTest._meta.get_field("year")
+ new_field = BigIntegerField()
+ new_field.set_attributes_from_name("year")
+ with connection.schema_editor() as editor:
+ editor.alter_field(UniqueTest, old_field, new_field, strict=True)
+ with self.assertRaises(IntegrityError):
+ UniqueTest.objects.create(year=None, slug='bbb')
+
def test_alter_null_to_not_null(self):
"""
#23609 - Tests handling of default values when altering from NULL to NOT NULL.