Reputation:
I would like to do a query to get all items with a string 'id' > a specified id.
The query select * from machine_thread where id > 'znRb1c_3TPytk-JoPX19Qw'
returns an item with the id zT4GabH3Qy2W6YIGh8Ku-w
In the other languages i am using (python, javascript) a string comparison will show that
'znRb1c_3TPytk-JoPX19Qw'
is greater than 'zT4GabH3Qy2W6YIGh8Ku-w'
. What is postgresql doing differently, and is there anyway I can use the same comparison across all environments for comparing string IDs?
Upvotes: 5
Views: 1420
Reputation: 28571
It is because of COLLATE
the PostgreSQL is using.
Execute SHOW LC_COLLATE
to see, what collation you are using.
The collation you want (the one python and javascript are using) is "C"
.
Example here
Details here
Upvotes: 7