Opened 12 years ago

Closed 11 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: dev
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

Description

http://ci.djangoproject.com/job/Django%20Oracle/88/database=oracle,python=python2.7/testReport/inspectdb.tests/

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

Change History (6)

comment:1 by Shai Berger, 11 years ago

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.

https://github.com/django/django/pull/1075 fixes (or, if you like, works around it).

comment:2 by Aymeric Augustin, 11 years ago

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 by Shai Berger, 11 years ago

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 by Aymeric Augustin, 11 years ago

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 by Shai Berger, 11 years ago

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

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

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