im not able to reproduce this problem, i can send unicode() into
get_by or SQL constructs directly no problem. i also dont
immediately see anything that could cause it to construe a unicode
string as anything other than a literal value (unless the unicode()
function on your end is being clobered by something?) can you attach
a fully working test case ?
I'm using Postgresql 8.1.3 on Linux. The attached test case produces the following output on both of my machines:
____SNIP_____
> python test.py
working: dennis
Traceback (most recent call last):
File "test.py", line 30, in ?
t=Test.get_by(username=unicode('dennis'))
File "build/bdist.linux-i686/egg/sqlalchemy/mapping/mapper.py", line 258, in get_by
File "build/bdist.linux-i686/egg/sqlalchemy/mapping/query.py", line 58, in get_by
File "build/bdist.linux-i686/egg/sqlalchemy/mapping/query.py", line 137, in select_whereclause
File "build/bdist.linux-i686/egg/sqlalchemy/mapping/query.py", line 213, in _select_statement
File "build/bdist.linux-i686/egg/sqlalchemy/sql.py", line 473, in execute
File "build/bdist.linux-i686/egg/sqlalchemy/sql.py", line 378, in execute
File "build/bdist.linux-i686/egg/sqlalchemy/sql.py", line 355, in execute
File "build/bdist.linux-i686/egg/sqlalchemy/engine.py", line 646, in execute_compiled
File "build/bdist.linux-i686/egg/sqlalchemy/engine.py", line 641, in proxy
File "build/bdist.linux-i686/egg/sqlalchemy/engine.py", line 692, in execute
File "build/bdist.linux-i686/egg/sqlalchemy/engine.py", line 712, in _execute
sqlalchemy.exceptions.SQLError: (ProgrammingError) ERROR: column "dennis" does not exist
SELECT test.username AS test_username, test.id AS test_id
FROM test
WHERE test.username = dennis
LIMIT 1 'SELECT test.username AS test_username, test.id AS test_id \nFROM test \nWHERE test.username = %(test_username)s \n LIMIT 1' {'test_username': u'dennis'}
_____END SNIP_________
Let me know if you need any additional information about my environment or library versions. (SQLAlchemy 0.1.7)
Thanks
-Dennis
from sqlalchemy import *
engine = create_engine ( 'postgres://host=localhost&user=dennis&password=dennis&database=test' ); test_table = Table ( 'test', engine, Column ( 'id' , Integer, primary_key=True), Column ( 'username', VARCHAR(12)), ) class Test(object): pass assign_mapper(Test,test_table) try: test_table.drop() except: pass test_table.create() t=Test() t.username='dennis' objectstore.commit() t=Test.get_by(username='dennis') print 'working: %s' % t.username t=Test.get_by(username=unicode('dennis'))