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
Cannot handle multibyte characters (ie. Japanese) #134
Comments
Confirmed that this is a bug. I'll have to drill down and find out where that error is coming from (possibly in psycopg2). Sorry about the trouble. I'll see if I can fix it soon. Thank you for reporting. |
This works correctly in Python 3. I think I just need to wrap the inputs in unicode and it should work. |
I did some testing and found out that this is an inconsistency in But this bug doesn't affect the sql statments that return unicode values that are stored in the database. For ex:
So if multi-byte char values are stored in the database and we retrieve them, then they are rendered correctly. But it fails to render correctly when we do a no op such as
|
Thank you for looking at this! My initial test was with a table that contained Japanese characters, so if that works now, that's great! I can help to test, if it's working, but can I just install the latest version with |
It seems that this is a postgresql feature. Not a bug. |
@dkastl I haven't released the latest version to PyPI. You can install pgcli directly from this git repo using the following command:
Can you please try that and let me know if that fixes your issue? Thanks! |
@amjith Thank you! It worked now as you said, when I select from an actual table. So for "normal" tables it works, but for tables with an Well, this is now a not so common use case, and it was just a coincidence, that I tested it with a table, that uses But for completeness, here the SQL to reproduce it:
Then the query for id 1 and 2 work, the query for id 3 fails:
Using psql console works for all cases. |
I'm not too familiar with the hstore. I know it's the no-sql feature of postgres. Does it mean that the 'attribute' column won't have a datatype (such as varchar?). Because the author of psycopg2 shed some light on why the simple case of I'll have to check what is the type returned by hstore. I'll see how to handle this properly. Thanks for the detailed test case. I appreciate it very much. :) |
Well, I just use
The following query actually works, if you cast as
So the explanation makes sense and it seems to be a problem of unknown datatype. If you cast the hstore column as
Would it make sense to cast any |
I've fixed it temporarily by adding a unicode type-caster for hstore. But I've also requested psycopg2 author to default to unicode instead of utf-8 string. Can you try installing the code from master and try again?
Thanks! |
Thanks!
The way I uninstalled it before didn't work.
... but it seems it didn't update or it still doesn't work to run |
I think you might need a
|
Hmm, did not work after upgrading (which required the flag |
I've reopened the issue. This is what I did to test the hstore issue after the fix.
Can you tell me what's the structure of the table you're trying this on? |
It's exactly the same example you're using as described in a previous comment. |
I'll try and release the new version soon. I'm waiting to merge in a big pull request that adds schema support. Otherwise I'd release it today. Sorry about the wait. |
No problem at all. I was just interested trying out pgcli. The schema support is even more important for me. Thanks a lot for your work! |
I don't know if this is relevant or not, but pressing any key in Persian layout, crash pgcli , Can not even type a single persian character.
Using the current master 27a363e in a Debian 7 (whezy) in a docker container. |
It looks like the error might be coming from prompt_toolkit library. Since you have prompt_toolkit installed (as part of the dependency), can you try launching |
Yes. I think its prompt_toolkit
Do I need to report it some where else? |
This is prompt-toolkit's github issues page: https://github.com/jonathanslenders/python-prompt-toolkit/issues I'd file it myself, but without the ability to reproduce it, I'm not sure I can provide enough details. |
@dkastl Previously when I fixed the unicode issue with hstore, I didn't fix it the right way. That's why you weren't able to get it to work. I was basically hardcoding the oid for hstore which is wrong. Because the oid for hstore will be different for each database. I have now fixed the issue (the right way) and released a new version (0.16.1) to PyPI. If you do a Sorry about the wrong fix. :( |
@amjith Thanks a lot! |
It seems, that multibyte characters are not supported at all.
The following example uses Japanese characters:
With PSQL:
With PGCLI:
You will receive the same error for every query, that has to deal with a table containing multibyte characters.
The text was updated successfully, but these errors were encountered: