Description

Because RawQuerySet doesn't invoke the sql compiler, the ops.convert_values method in the Oracle backend never gets called. As a result, several values come through in the wrong format -- most notably, TextField values get pulled in as a cx_Oracle LOB object rather than as a Unicode string.

The complication with just adding a call to the method is that when using the other backends, it only ever gets called in an aggregation query. Outside of this context, it breaks. The method needs a closer examination to determine when it should be called and exactly what it should be doing.

Change History (10)

We don't necessarily need to call the other backends .convert_values directly. We could still potentially do it through the SQLCompiler on the backend so that it functions equivalently to the main QuerySet class. However, post-1.2 it's been discussed on IRC that the base convert_values method does need a review and update to handle cases outside of aggregates more intelligently.

(In [12904]) Fixed #12429 -- Ensure that raw queries call resolve_columns if the backend defines it. This ensures (as much as possible) that the model values returned by a raw query match that in normal queries. Thanks to Ian Kelly for the report.

r12904 doesn't quite work for Oracle: the raw_query tests now all result in an error due to the fact that RawQuery does not have a high_mark attribute. From the line of code in the traceback (I only included one, they are all the same) I suspect low_mark is going to be a problem too...