I am finally at the tail end of migrating my largest (and hopefully last) Python2 application to Python3.
An issue that has popped up a lot during this transition, is when a py3 bytestring gets submitted into SqlAlchemy.
When that happens, it looks like SqlAlchemy just passes the value into psycopg2, which wraps it in an object, and I get a psycopg exception that bubbles up to SqlAlchemy:
> sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedFunction) operator does not exist: character varying = bytea
> LINE 3: WHERE foo = '\x626337323133...
> HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
> ....
> WHERE foo = %(foo)s
> LIMIT %(param_1)s]
> [parameters: {'foo': <psycopg2.extensions.Binary object at 0x10fe99060>, 'param_1': 1}]
> (Background on this error at:
http://sqlalche.me/e/13/f405)
Is there an easy way to catch this in SQLAlchemy *before* sending this to the driver and executing it on the server? I'd like to ensure I'm catching everything I should, and nothing is working just by-chance.