mirror of
https://github.com/django/django.git
synced 2025-10-29 08:36:09 +00:00
Fixed #19299 -- Fixed Nullification of Foreign Keys To CharFields
Thanks tunixman for the report and Baptiste Mispelon and Shai Berger for reviews.
This commit is contained in:
@@ -1416,9 +1416,12 @@ def get_cached_row(row, index_start, using, klass_info, offset=0,
|
||||
klass, field_names, field_count, related_fields, reverse_related_fields, pk_idx = klass_info
|
||||
|
||||
fields = row[index_start:index_start + field_count]
|
||||
# If the pk column is None (or the Oracle equivalent ''), then the related
|
||||
# If the pk column is None (or the equivalent '' in the case the
|
||||
# connection interprets empty strings as nulls), then the related
|
||||
# object must be non-existent - set the relation to None.
|
||||
if fields[pk_idx] is None or fields[pk_idx] == '':
|
||||
if (fields[pk_idx] is None or
|
||||
(connections[using].features.interprets_empty_strings_as_nulls and
|
||||
fields[pk_idx] == '')):
|
||||
obj = None
|
||||
elif field_names:
|
||||
fields = list(fields)
|
||||
|
||||
Reference in New Issue
Block a user