Opened 12 years ago
Closed 12 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
Roughly, the failure happens because the module enables unicode_literals
, but Oracle returns table names as bytestrings.
Change History (6)
comment:1 by , 12 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:2 by , 12 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 , 12 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 , 12 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 , 12 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 , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
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).