Opened 12 years ago
Closed 12 years ago
#19448 closed Cleanup/optimization (duplicate)
BaseDatabaseFeatures convert_values
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Core (Other) | Version: | 1.4 |
Severity: | Normal | Keywords: | convert_values |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In django.db.backends there is convert_values function. I have declared custom field which corresponds to Postgresql interval type. By default convert_values assumes that unknown type is float. Is it possible to change this behaviour? Like that (look at return):
def convert_values(self, value, field): """Coerce the value returned by the database backend into a consistent type that is compatible with the field type. """ internal_type = field.get_internal_type() if internal_type == 'DecimalField': return value elif internal_type and internal_type.endswith('IntegerField') or internal_type == 'AutoField': return int(value) elif internal_type in ('DateField', 'DateTimeField', 'TimeField'): return value # No field, or the field isn't known to be a decimal or integer # Default to a float #return float(value) #Not to a float. Just leave as is return value
Note:
See TracTickets
for help on using tickets.
This is a duplicate of the already fixed ticket #13844 (will be in 1.5)