Re: [Sqlalchemy-tickets] [sqlalchemy] #2906: Unicode/UnicodeText return str instead of unicode on M
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2014-01-10 19:18:16
|
#2906: Unicode/UnicodeText return str instead of unicode on MySQL-Python 1.2.3
----------------------------------+------------------------------------
Reporter: stevejohnson | Owner:
Type: defect | Status: new
Priority: medium | Milestone:
Component: mysql | Severity: no triage selected yet
Resolution: | Keywords:
Progress State: awaiting triage |
----------------------------------+------------------------------------
Comment (by zzzeek):
ok here's the one way this can go wrong. try out this script:
{{{
#!python
from sqlalchemy import create_engine
from sqlalchemy.sql import expression
from sqlalchemy import types as sqltypes
engine = create_engine("mysql://scott:tiger@localhost/test?charset=utf8")
dialect = engine.dialect
connection = engine.connect()
cursor = connection.connection.cursor()
def ret_type(type_):
cursor.execute(
str(
expression.select(
[expression.cast(
expression.literal_column(
"'test plain returns'"),
type_)
]).compile(dialect=dialect)
)
)
row = cursor.fetchone()
print type(row[0])
ret_type(sqltypes.VARCHAR(60))
ret_type(sqltypes.TEXT)
}}}
if the two types printed out aren't consistent, that could cause this
issue. MySQL-python 1.2.3 for me here reports "unicode" for both.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2906#comment:1>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|