Marcin Krol wrote: > Hello everyone, > > To refresh my familiarity with SQLAlchemy I wrote a sample "app", and > used: > > engine = create_engine("postgres://postgres:*...@localhost/ts", > convert_unicode=True, assert_unicode=True) > > Then I passed a few strings in an object added via session.add() and one > of those strings was not Unicode. SQLAlchemy displayed warning: > > C:\Python26\lib\site-packages\sqlalchemy-0.5.8-py2.6.egg\sqlalchemy\engine\default.py:242: > SAWarning: Unicode type received non-unicode bind param value 'Jane Shmoe' > param[key.encode(encoding)] = processors[key](compiled_params[key]) > > > I was led to believe by doc on create_engine that this would raise an > error: > > :param assert_unicode=False: When set to ``True`` alongside > convert_unicode=``True``, asserts that incoming string bind > parameters are instances of ``unicode``, otherwise raises an > error. Only takes effect when ``convert_unicode==True``. > > I would need this to be error rather than warning just like docs say > (well I'd rather have it crash & then debug than write bad values into db) > > SQA is 0.5.8, win32 if that's of any importance.
the assert_unicode flag is not ideal - a Unicode type sets it to "warn" which overrides the engine-level setting. The engine level setting is more for just all the String types to use. This qualifies as a bug but at the same time I think using the warnings filter is a better approach overall. > > Regards, > mk > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalch...@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.