#19606 closed Bug (fixed)
Oracle unicode insert fails.
Reported by: | Jani Tiainen | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.4 |
Severity: | Normal | Keywords: | oracle orm unicode |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
smart_str (which detection selects) does not work.
using force_unicode works (except for connection string).
Depending on what OCI client 10.2.0.5 or instant client 11.2 is used when compiling cx_Oracle causes variation. 10.2.0.5 doesn't work with smart_str while 11.2 does work.
Both can take plain unicode (u'<some unicode stuff here>') when using just cx_Oracle directly without any problems.
Note:
If I add manually some unicode to database Django can read it without any problems.
Change History (9)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Triage Stage: | Unreviewed → Accepted |
---|
I haven't haven't been able to verify this (no 10.2.0.5 here). The report seems well researched in the django-users thread so accepted based on that.
comment:3 by , 12 years ago
Problem is that Django makes incorrect detection what to string encoding system to use:
I did also some source code diving to make sure how this works:
In version 5.0.x cx_Oracle.UNICODE is only defined if code was compiled without flag WITH_UNICODE.
In version 5.1+ cx_Oracle.UNICODE is always defined if Python major version compiled against is < 3.
According to changelog of cx_Oracle:
Changes from 5.0.4 to 5.1
1) Remove support for UNICODE mode and permit Unicode to be passed through in
everywhere a string may be passed in. This means that strings will be
passed through to Oracle using the value of the NLS_LANG environment
variable in Python 3.x as well. Doing this eliminated a bunch of problems
that were discovered by using UNICODE mode and also removed an unnecessary
restriction in Python 2.x that Unicode could not be used in connect strings
or SQL statements, for example.
So behaviour should be: If cx_Oracle version is greater or equal to 5.1 real unicode should be used always. With pre-5.1 current behaviour is sufficient.
comment:4 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:6 by , 12 years ago
I felt very uncomfortable about backporting this as I can't actually test the combo this is supposed to fix - that is, cx_oracle 5.1 + instantclient 10.2 as that wont compile on my machine. Based on the patch, cx_oracle 5.0 users should no get any change and I have tested 5.1 + instantclient 11.
I think this falls into the category of patches we can still backpatch to 1.5 at this stage - the combination of cx_oracle 5.1 + instantclient 10.2 is supported, but it doesn't work with unicode values currently.
So, after using too much time trying to tests this, I did backpatch this on the grounds that instanclient 11 works, cx_oracle 5.0 works as always, and the research done by jtiai shows that this is the right thing to do for 5.0 + instantclient 10.
comment:7 by , 12 years ago
According to my research it's all about version of cx_Oracle 5.0.x series does behave have slightly different definition for cx_Oracle.UNICODE than 5.1.x
It has nothing to do with OCI version linked against even I though that was the reason. But I think 1.5 is sufficient at this point.
comment:9 by , 11 years ago
#20292 is possibly related, at least reverting this change fixes that bug.
Original story - https://groups.google.com/forum/?fromgroups=#!topic/django-users/fXB4wReYth0