Opened 7 years ago

Closed 7 years ago

#7036 closed (fixed)

Oracle backend broken on queryset-refactor

Reported by: mtredinnick Owned by: nobody
Component: Database layer (models, ORM) Version: queryset-refactor
Severity: Keywords: qs-rf
Cc: ikelly Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Noting this here in case anybody is trying to use queryset-refactor and Oracle...

At some point in the recent past, I've managed to completely break Oracle backend. Ian Kelly reports a whole bunch of failures when running the test suite that look like

 File "/home/ikelly/projects/django.qs-rf/django/db/models/query.py",
line 156, in iterator
   obj = self.model(*row[index_start:])
 File "/home/ikelly/projects/django.qs-rf/django/db/models/base.py",
line 205, in __init__
   raise IndexError("Number of args exceeds number of fields")
IndexError: Number of args exceeds number of fields

My guess is that the resolve_columns() method in django.db.backend.oracle.query.OracleQuery needs updating in light of the changes in [7340] (which moved the "extra" select columns to the front of the output columns list), but that's just a guess.

Attachments (2)

oracle_resolve_columns_fix.patch (1.2 KB) - added by jbronn 7 years ago.
Fix for OracleQuery.resolve_columns due to changes in #7340.
7036_redux.diff (2.0 KB) - added by ikelly 7 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 7 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Changed 7 years ago by jbronn

Fix for OracleQuery.resolve_columns due to changes in #7340.

comment:2 Changed 7 years ago by Alex

  • Has patch set

comment:3 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(In [7438]) queryset-refactor: Fixed db column to model field mapping for Oracle backend.
Thanks, Justin Bronn. Fixed #7036.

comment:4 Changed 7 years ago by ikelly

  • Keywords qs-rf added
  • Resolution fixed deleted
  • Status changed from closed to reopened

I'm reopening this because it's not a complete fix. The patch fixes the immediate problem, but it also removes all extra_select columns from the result set returned by Oracle, which causes queries that use extra_select to go haywire.

Just putting the extra_select columns back into the returned row causes the original error to occur again, and it turns out that the reason for this is that OracleQuery.as_sql is adding the 'rn' column to the extra_select after the QuerySet.iterator method has polled it to determine the number of extra_select columns. So OracleQuery.as_sql should not be adding anything to extra_select, period. The new patch fixes this by adding a row number placeholder to extra_select at the time Query.set_limits is called.

Changed 7 years ago by ikelly

comment:5 Changed 7 years ago by ikelly

  • Cc ikelly added

comment:6 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from reopened to closed

Fixed in [7443]. Thanks, Ian.

Note: See TracTickets for help on using tickets.
Back to Top