New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support special characters for similarity queries #1182
Conversation
@procrastinatio please review |
Hmm, do not understand why you have to convert to ascii, the column type in the model should be |
match.group(2).replace('\'', '\\\''), | ||
match.group(3) | ||
)) | ||
where = where.encode('ascii', 'replace') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to convert to ascii ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because sqlAlchemy uses ascii to build plain SQL requests (this is where it fails).
replace argument replaces all the non-ascii characters with ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really up to date here, but e.g. ü
is a non-ascii character, but doesn't cause any problems?
The error is unrelated to encoding errors, it is simply a matter of properly escape special characters in the partial SQL request. Normally, it is best to leave SQLAlchemy do the job. |
OK. |
and |
I know why prod and dev are behaving diffrently. pyramid_debugtoolbar is bugged see Pylons/pyramid_debugtoolbar#60 |
This PR is for: geoadmin/mf-geoadmin3#2009
At some point the where
unicode
will be converted to bytestr
and will fail because for some reason we have non-ASCII unicode strings.The famous
UnicodeError
...Here we
\
and telling postrgres to escape it with E)str
and replace unmapped characters with?
that we finally replace with%
It's a workaround but it works fine.
If anybody has a better solution/understanding of what's going on please feel free.
Current Link in prod
Deployed Branch in test