Potential data corruption issue with Oracle and Mysql due to SQLCompiler.resolve_columns row, fields misalignment
|Reported by:||manfre||Owned by:||manfre|
|Component:||Database layer (models, ORM)||Version:||1.5|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||yes||Patch needs improvement:||yes|
When a query is annotated, the aggregate_select values are included in the row, but there are no matching entries in the fields list. This results in the values and fields getting misaligned when attempting to convert the database value to a python value.
Problem can be viewed by adding the following to the top of the for loop in either oracle's or mysql's SQLCompiler.resolve_columns methods:
print '\tfield= %s\tvalue=%s' % (repr(field), value)
Run the test aggregation_regress.AggregationTests.test_more_more and grep for "Peter Norvig" to see that is paired with the "age" column.
Depending on the specific query and data, this can result in the incorrect conversion being applied to the data, which might result in data corruption or an unexpected exception.
Change History (26)
comment:1 Changed 6 months ago by akaariai
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted
- Type changed from Uncategorized to Bug
comment:2 Changed 6 months ago by manfre
- Has patch set
- Owner changed from nobody to manfre
- Status changed from new to assigned
comment:13 Changed 6 months ago by Anssi Kääriäinen <akaariai@…>
- Resolution set to fixed
- Status changed from assigned to closed