I have a question about inconsistency in unicode handling when using a
bindparam explicitly and when using a literal when constructing my
query. It appears that if I use a unicode object in the actual query
whereclause, the convert_bind_param function of the base String will
get called(query1). However, if I use a bindparam in the whereclause
and then pass in the unicode object as the bindparam,
convert_bind_param is not called(query2).
The code below demonstrates what I am talking about. Is there a reason
that these two ways of constructing a query should have inconsistent
behavior? If I am missing something, I would appreciate any info that
would make it clear to me as to why this is the expected behavior.
Thanks,
DY
import sqlalchemy
meta = sqlalchemy.DynamicMetaData()
meta.connect ('mysql://some_dsn')
test = sqlalchemy.Table('my_test_table', meta,
sqlalchemy.Column('id', sqlalchemy.Integer, primary_key=True),
sqlalchemy.Column ('name', sqlalchemy.Unicode (255)),
mysql_engine='InnoDB',
)
query1 = sqlalchemy.select([test],
sqlalchemy.and_ (
test.c.id == sqlalchemy.bindparam ('id'),
test.c.name == u'\u201csolutions\u201d',
#option 1
)
)
results = query1.execute(id=1)
query2 = sqlalchemy.select([test],
sqlalchemy.and_ (
test.c.id == sqlalchemy.bindparam ('id'),
test.c.name == sqlalchemy.bindparam('name'),
)
)
results = query2.execute(id=1, name=u'\u201csolutions\u201d')
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---