Oracle support for queryset-refactor.
|Reported by:||jbronn||Owned by:||Malcolm Tredinnick|
|Component:||Database layer (models, ORM)||Version:||other branch|
|Cc:||jbronn@…, Ian Kelly||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I was playing around w/qs-rf branch and successfully merged it w/GeoDjango (there are a few minor tweaks I had make to
Query, but otherwise it went well -- I will try and give these diffs to Malcolm later). Because GeoDjango supports Oracle, I decided to try it out, but noticed that the
OracleQuerySet had not been modified to be compatible w/queryset-refactor changes.
Attached is the patch I used to enable Oracle functionality under the queryset-refactor branch. Essentially, I added an
OracleQuery subclass that has
resolve_columns from the original
OracleQuerySet and and overrides the
as_sql method to deal with the peculiarities of limit/offset SQL in Oracle. The new
OracleQuerySet subclass just overrides
__init__ to use
OracleQuery. There is probably a more elegant way of using qs-rf facilities (e.g., using
get_from_clause the way
count() does), but it appears to work well enough to pass all GeoDjango tests (not confirmed w/Django tests).
Another change (that has been in GeoDjango for a while) is the modification of the
_format_params routine in
FormatStylePlaceholderCursor. Because GeoDjango performs spatial queries w/CLOBs (to store WKT geometries), the
setinputsizes routine needs to be called. With the patch,
_format_params looks to see if the parameter has an
oracle_type method, and if it does it will call
setinputsizes with the result of
oracle_type. For an example of how this is used see the Oracle [browser:django/branches/gis/django/contrib/gis/db/backend/oracle/adaptor.py geometry adaptor class] of GeoDjango.