Opened 6 years ago

Closed 6 years ago

#20386 closed Bug (fixed)

Four tests for inspectdb fail under Oracle

Reported by: Aymeric Augustin Owned by: Shai Berger
Component: Database layer (models, ORM) Version: master
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Roughly, the failure happens because the module enables unicode_literals, but Oracle returns table names as bytestrings.

Change History (6)

comment:1 Changed 6 years ago by Shai Berger

Has patch: set
Owner: changed from nobody to Shai Berger
Status: newassigned

Beh. cx_Oracle returns a str as the column name, whether we are on python2 or python3. Arguably a cx_Oracle bug. fixes (or, if you like, works around it).

comment:2 Changed 6 years ago by Aymeric Augustin

Thanks for finding the right spot for fixing this.

I'd write the patch a bit differently:

from django.utils.encoding import force_text


name = force_text(desc[0])

comment:3 Changed 6 years ago by Shai Berger

I'm not sure it's an improvement -- force_text deals with all sorts of non-strings and lazy objects, and seems a bit overkill for this case where we know exactly what the object is. However, I won't argue too much about it.

comment:4 Changed 6 years ago by Aymeric Augustin

You're right, I've considered introducing another API just to cover the utf-8 str / unicode case.

But we're already using force_text throughout the code base and it does the job just fine. I think the conditional branches for str / unicode are early in the function so it's fast.

comment:5 Changed 6 years ago by Shai Berger

As I said, I don't feel very attached to the three lines. force_text will definitely do the job.

comment:6 Changed 6 years ago by Shai Berger <shai.berger@…>

Resolution: fixed
Status: assignedclosed

In 215647c0f7614abe4fe0cd76bc70dd7b02f829b4:

Fixed #20386 - Introspection problem on Oracle

Made introspection always return a unicode as column name on Oracle.
Thanks aaugustin for review and suggestion to use force_text().

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