1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Refs #35381 -- Delegated ArrayField element prepping to base_field.get_db_prep_save.

Previously, ArrayField always used base_field.get_db_prep_value when saving,
which could differ from how base_field prepares data for save. This change
overrides ArrayField.get_db_prep_save to delegate to the base_field's
get_db_prep_save, ensuring elements like None in JSONField arrays are saved
correctly as SQL NULL instead of JSON null.
This commit is contained in:
Clifford Gama
2025-10-21 11:34:58 +02:00
committed by Jacob Walls
parent adc25a9a66
commit be7f68422d
4 changed files with 42 additions and 1 deletions

View File

@@ -79,7 +79,7 @@ class OtherTypesArrayModel(PostgreSQLModel):
models.DecimalField(max_digits=5, decimal_places=2), default=list
)
tags = ArrayField(TagField(), blank=True, null=True)
json = ArrayField(models.JSONField(default=dict), default=list)
json = ArrayField(models.JSONField(default=dict), default=list, null=True)
int_ranges = ArrayField(IntegerRangeField(), blank=True, null=True)
bigint_ranges = ArrayField(BigIntegerRangeField(), blank=True, null=True)