Potential data corruption issue with Oracle and Mysql due to SQLCompiler.resolve_columns row, fields misalignment
|Reported by:||Michael Manfre||Owned by:||Michael Manfre|
|Component:||Database layer (models, ORM)||Version:||1.5|
|Cc:||Simon Charette||Triage Stage:||Accepted|
|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:2 Changed 4 years ago by
|Owner:||changed from nobody to Michael Manfre|
|Status:||new → assigned|