Skip to content

Can't compare strings when COLLATE'ing (But I can when using pgx/v5??) #117849

Answered by yuzefovich
Nintron27 asked this question in Q&A
Discussion options

You must be logged in to vote

In short, what happens with the problematic statement is that untyped string 'John' is treated by CRDB as STRING type, and comparing a collated string against a "regular" string isn't supported, so you must help the type checker a bit (e.g. by adding an explicit cast).

My guess is that sqlc automatically adds the casts for you, so the statement that is actually executed is not

SELECT created_at FROM "user" WHERE username = 'John';

but is something like:

SELECT created_at FROM "user" WHERE username = 'John'::VARCHAR(32) COLLATE "en-US-u-ks-level2";

which works.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Nintron27
Comment options

Answer selected by Nintron27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants