pyeve / eve-sqlalchemy

SQLAlchemy data layer for Eve-powered RESTful APIs
http://eve-sqlalchemy.readthedocs.io
Other
234 stars 70 forks source link

UnicodeEncodeError when filtering unicode string #58

Closed terrysclaw closed 9 years ago

terrysclaw commented 9 years ago

http://127.0.0.1:5000/api/v1/user_profiles?where={"name":"like(\"%25林%\")"}

File "C:\Users\SiuCheongTerry\OneDrive\Projects\to-do\tochange.com.hk\server\venv\lib\site-packages\eve_sqlalchemy\parser.py", line 43, in parse_dictionary conditions += parse('{0}{1}'.format(k, v), model) UnicodeEncodeError: 'ascii' codec can't encode character u'\u6797' in position 7: ordinal not in range(128)

parser.py line 42-47 try: conditions += parse('{0}{1}'.format(k, v), model) except ParseError: pass else: continue

to...

    try:
        if(type(v) is unicode):
            conditions += parse('{0}{1}'.format(k, v.encode('utf-8')), model)
        else:
            conditions += parse('{0}{1}'.format(k, v), model)
    except ParseError:
        pass
    else:
        continue
amleczko commented 9 years ago

can you convert this issues to PR with a small test?

terrysclaw commented 9 years ago

Hi amleczko, How to convert to PR?

I want to be a contributor.

amleczko commented 9 years ago

It would be great! Please read https://help.github.com/articles/creating-a-pull-request/ and https://help.github.com/articles/using-pull-requests/

amleczko commented 9 years ago

Thanks!