Re: ORM, Oracle and UTF-8 encoding problem.
9.1.2013 12:28, Ian kirjoitti:
> On Wednesday, January 9, 2013 12:38:28 AM UTC-7, Jani Tiainen wrote:
>
> Tested against latest master. Same behaviour.
>
> In Oracle backend base.py is following piece of code:
>
> # Check whether cx_Oracle was compiled with the WITH_UNICODE option.
> This will
> # also be True in Python 3.0.
> if int(Database.version.split('.', 1)[0]) >= 5 and not
> hasattr(Database,
> 'UNICODE'):
> convert_unicode = force_text
> else:
> convert_unicode = force_bytes
>
> Which was added in
> <https://github.com/django/django/commit/dcf3be7a62
> <https://github.com/django/django/commit/dcf3be7a62>>
>
> Thing is that my cx_Oracle is version 5.1.2, it has cx_Oracle.UNICODE
> definition.
>
>
> That sounds correct. The cx_Oracle.UNICODE type constant is present
> when cx_Oracle is compiled *without* the WITH_UNICODE option (which no
> longer exists in 5.1 anyway).
>
> And Django uses smart_str / force_bytes.
>
> If I remove that and use convert_unicode as force_text / force_unicode
> everything works as expected.
>
>
> Strange, in 5.1 it shouldn't make any difference which is used, as long
> as your NLS_LANG is getting set properly in the backend. What is your
> server setup? It seems that sometimes that can get interfered with if
> you have other services using Oracle in the same process. It shouldn't
> hurt anything though for us to do an additional check for cx_Oracle 5.1+
> and always use force_text in that case.
Server is running Oracle Database 10g Release 10.2.0.5.0 - 64bit
Production. (EE edition)
and charset info:
NLS_CHARACTERSET WE8ISO8859P1
NLS_NCHAR_CHARACTERSET AL16UTF16
When cx_Oracle (Version 5.1.2) is compiled against 10.2.0.3 client:
I can insert unicode characters directly using cx_Oracle.
I can't insert unicode characters using ORM
I can't insert unicode characters using Django connection.cursor()
When cx_Oracle is compiled against instantclient 11.2 (multinational
version) I can do all of the above without the problems.
--
Jani Tiainen
- Well planned is half done and a half done has been sufficient before...
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home