Refs #28459 -- Made Oracle get_db_converters() return converter for empty strings only when it's needed.
This commit is contained in:
parent
5cb7619995
commit
22ff86ec52
|
@ -165,7 +165,15 @@ END;
|
||||||
converters.append(self.convert_timefield_value)
|
converters.append(self.convert_timefield_value)
|
||||||
elif internal_type == 'UUIDField':
|
elif internal_type == 'UUIDField':
|
||||||
converters.append(self.convert_uuidfield_value)
|
converters.append(self.convert_uuidfield_value)
|
||||||
converters.append(self.convert_empty_values)
|
# Oracle stores empty strings as null. If the field accepts the empty
|
||||||
|
# string, undo this to adhere to the Django convention of using
|
||||||
|
# the empty string instead of null.
|
||||||
|
if expression.field.empty_strings_allowed:
|
||||||
|
converters.append(
|
||||||
|
self.convert_empty_bytes
|
||||||
|
if internal_type == 'BinaryField' else
|
||||||
|
self.convert_empty_string
|
||||||
|
)
|
||||||
return converters
|
return converters
|
||||||
|
|
||||||
def convert_textfield_value(self, value, expression, connection):
|
def convert_textfield_value(self, value, expression, connection):
|
||||||
|
@ -208,17 +216,13 @@ END;
|
||||||
value = uuid.UUID(value)
|
value = uuid.UUID(value)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def convert_empty_values(self, value, expression, connection):
|
@staticmethod
|
||||||
# Oracle stores empty strings as null. We need to undo this in
|
def convert_empty_string(value, expression, connection):
|
||||||
# order to adhere to the Django convention of using the empty
|
return '' if value is None else value
|
||||||
# string instead of null, but only if the field accepts the
|
|
||||||
# empty string.
|
@staticmethod
|
||||||
field = expression.output_field
|
def convert_empty_bytes(value, expression, connection):
|
||||||
if value is None and field.empty_strings_allowed:
|
return b'' if value is None else value
|
||||||
value = ''
|
|
||||||
if field.get_internal_type() == 'BinaryField':
|
|
||||||
value = b''
|
|
||||||
return value
|
|
||||||
|
|
||||||
def deferrable_sql(self):
|
def deferrable_sql(self):
|
||||||
return " DEFERRABLE INITIALLY DEFERRED"
|
return " DEFERRABLE INITIALLY DEFERRED"
|
||||||
|
|
Loading…
Reference in New Issue