Skip to content
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

ORDER BY not working with capital case #132

Open
rayaanrizwan1234 opened this issue Apr 2, 2024 · 3 comments
Open

ORDER BY not working with capital case #132

rayaanrizwan1234 opened this issue Apr 2, 2024 · 3 comments

Comments

@rayaanrizwan1234
Copy link

rayaanrizwan1234 commented Apr 2, 2024

When doing an ORDER BY ASC it seems to get back the ones with capital case first. For example, if we had a column and a record with 'Z' and another with 'a', doing an ORDER BY ASC on that column will bring the record with 'Z' first then the other. Any way to fix this?

org.opentest4j.AssertionFailedError: expected: <[SimpleLookup(code=null - null, description=Desc, active=true), SimpleLookup(code=null - RG, description=Desc, active=true)]> but was: <[SimpleLookup(code=null - RG, description=Desc, active=true), SimpleLookup(code=null - null, description=Desc, active=true)]> at app//org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151) at app//org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132) at app//org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197) at app//org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:182) at app//org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:177) at app//org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1145)

@lesiak
Copy link

lesiak commented Apr 8, 2024

This is not a bug - it is a consequence how letters are represented.

For example in Unicode:
List of Unicode characters - Latin Script

  • Z - Latin Capital letter Z - code 90
  • a - Latin Small Letter A - code 97

Thus Z goes before a.

If you want to compare ignoring the case, convert both sides to same case using UPPER(columnA) or LOWER(columnA).

If you want more details:
You may be using a different character set for strings: 24.3.1. Supported Character Sets
However, the code points for Latin Script are shared across many character sets, and were introduced by ASCII encoding

@tomix26
Copy link
Collaborator

tomix26 commented Apr 8, 2024

I'm not an expert in this area, but I think it should also be possible to use ICU collation settings:

@rayaanrizwan1234
Copy link
Author

Thanks for getting back on this. What character set does the embedded Postgres use? and is there a way to specify which one it uses?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants