Refs #27808 -- Added test for saving nested ArrayField with nullable base field.
This commit is contained in:
parent
a699595fce
commit
8463390527
|
@ -96,6 +96,10 @@ class Migration(migrations.Migration):
|
|||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('field', ArrayField(models.IntegerField(), size=None, null=True, blank=True)),
|
||||
(
|
||||
'field_nested',
|
||||
ArrayField(ArrayField(models.IntegerField(), size=None, null=True), size=None, null=True),
|
||||
),
|
||||
],
|
||||
options={
|
||||
'required_db_vendor': 'postgresql',
|
||||
|
|
|
@ -46,6 +46,7 @@ class IntegerArrayModel(PostgreSQLModel):
|
|||
|
||||
class NullableIntegerArrayModel(PostgreSQLModel):
|
||||
field = ArrayField(models.IntegerField(), blank=True, null=True)
|
||||
field_nested = ArrayField(ArrayField(models.IntegerField(null=True)), null=True)
|
||||
|
||||
|
||||
class CharArrayModel(PostgreSQLModel):
|
||||
|
|
|
@ -31,6 +31,7 @@ try:
|
|||
from django.contrib.postgres.forms import (
|
||||
SimpleArrayField, SplitArrayField, SplitArrayWidget,
|
||||
)
|
||||
from django.db.backends.postgresql.base import PSYCOPG2_VERSION
|
||||
from psycopg2.extras import NumericRange
|
||||
except ImportError:
|
||||
pass
|
||||
|
@ -140,6 +141,14 @@ class TestSaveLoad(PostgreSQLTestCase):
|
|||
self.assertEqual(field.model, IntegerArrayModel)
|
||||
self.assertEqual(field.base_field.model, IntegerArrayModel)
|
||||
|
||||
def test_nested_nullable_base_field(self):
|
||||
if PSYCOPG2_VERSION < (2, 7, 5):
|
||||
self.skipTest('See https://github.com/psycopg/psycopg2/issues/325')
|
||||
instance = NullableIntegerArrayModel.objects.create(
|
||||
field_nested=[[None, None], [None, None]],
|
||||
)
|
||||
self.assertEqual(instance.field_nested, [[None, None], [None, None]])
|
||||
|
||||
|
||||
class TestQuerying(PostgreSQLTestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue