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

Postgres UUID can't be used in values_ (+ fix) #555

Closed
roberth opened this issue Mar 10, 2021 · 2 comments · Fixed by #583
Closed

Postgres UUID can't be used in values_ (+ fix) #555

roberth opened this issue Mar 10, 2021 · 2 comments · Fixed by #583
Labels

Comments

@roberth
Copy link
Contributor

roberth commented Mar 10, 2021

The postgresql backend generates UUID strings without a type. Most of the time PostgreSQL is clever enough to infer the type, but when used in values_, it only infers locally, leading to missing cast errors down the line. This can be fixed by always appending ::uuid to UUIDs.
I haven't made a PR because I don't know where/how this should be changed. beam-postgres seems to borrow a lot of value syntax from postgresql-simple, which I'm not familiar with.
For my own application, I was able to change the syntax in my UUID newtype.

instance HasSqlValueSyntax PgValueSyntax (Id a) where
  sqlValueSyntax (Id uuid) = PgValueSyntax $ fromPgValue (sqlValueSyntax uuid) <> emit "::uuid"
@kmicklas kmicklas added the bug label Mar 14, 2021
@kmicklas
Copy link
Member

This looks like a postgres-simple bug but we could work around it by replacing DEFAULT_SQL_SYNTAX(UUID) with your instance.

@kmicklas
Copy link
Member

I've reported lpsmith/postgresql-simple#277 to see if it's possible to get this fixed upstream.

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

Successfully merging a pull request may close this issue.

2 participants