[Sqlalchemy-tickets] [sqlalchemy] #2856: Oracle error with reflect on table with cyrillic column na
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-10-31 17:01:19
|
#2856: Oracle error with reflect on table with cyrillic column names in
-------------------------------------+-------------------------------------
Reporter: teddy | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone:
Component: declarative | Severity: no triage selected
Keywords: oracle, cyrillic, | yet
declarative, reflexion | Progress State: awaiting triage
-------------------------------------+-------------------------------------
There is a bug with reflexion on cyrillic column names in Oracle.
Lets assume we have a table with such DDL:
{{{
#!sql
CREATE TABLE cyr_test (
"ИД" NUMBER CONSTRAINT id_demo NOT NULL,
"ПОЛЕ1" VARCHAR2,
"ЕЩЕПОЛЕ" VARCHAR2,
CONSTRAINT с_id_pk_demo PRIMARY KEY ("ИД")
);
}}}
So we try to reflect on this table in sqlalchemy:
{{{
#!python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sqlalchemy import *
from sqlalchemy.orm import sessionmaker
engine = create_engine('oracle+cx_oracle://<some_conn_string>,
encoding="windows-1251", optimize_limits=True, use_binds_for_limits=False,
echo='debug', coerce_to_decimal=False)
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base(bind=engine)
S = sessionmaker(bind=engine)
s = S()
class CyrTest(Base):
__table__ = Table("cyr_test", Base.metadata,
Column(u'ИД', Integer, primary_key=True),
oracle_resolve_synonyms=True,
autoload=True
)
}}}
And, getting this error:
{{{#!python
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "test.py", line 14, in <module>
class CyrTest(Base):
File "C:\Python27\lib\site-packages\sqlalchemy\ext\declarative\api.py",
line 5
0, in __init__
_as_declarative(cls, classname, cls.__dict__)
File "C:\Python27\lib\site-packages\sqlalchemy\ext\declarative\base.py",
line
292, in _as_declarative
mt.map()
File "C:\Python27\lib\site-packages\sqlalchemy\ext\declarative\base.py",
line
376, in map
**mapper_args
File "C:\Python27\lib\site-packages\sqlalchemy\orm\__init__.py", line
1229, in
mapper
return Mapper(class_, local_table, *args, **params)
File "C:\Python27\lib\site-packages\sqlalchemy\orm\mapper.py", line 219,
in __
init__
self._configure_properties()
File "C:\Python27\lib\site-packages\sqlalchemy\orm\mapper.py", line 904,
in _c
onfigure_properties
setparent=True)
File "C:\Python27\lib\site-packages\sqlalchemy\orm\mapper.py", line
1181, in _
configure_property
prop.instrument_class(self)
File "C:\Python27\lib\site-packages\sqlalchemy\orm\properties.py", line
128, i
n instrument_class
doc=self.doc
File "C:\Python27\lib\site-packages\sqlalchemy\orm\attributes.py", line
1449,
in register_descriptor
manager.instrument_attribute(key, descriptor)
File "C:\Python27\lib\site-packages\sqlalchemy\orm\instrumentation.py",
line 1
92, in instrument_attribute
self.install_descriptor(key, inst)
File "C:\Python27\lib\site-packages\sqlalchemy\orm\instrumentation.py",
line 2
44, in install_descriptor
setattr(self.class_, key, inst)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1:
ordin
al not in range(128)
}}}
With another table, without cyrillic column names, everything works fine.
Tested on sqlalchemy 0.8.1/0.8.3/0.9.0b1 in Python 2.7.2 (ActiveState
ActivePython 2.7.2.5), Windows 7 x64, Oracle 11g.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2856>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|