Skip to content

Add FromField and ToField instance for Data.UUID #89

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

Closed
wants to merge 1 commit into from

Conversation

mkoppmann
Copy link
Contributor

The implementation is based on postgresql-simple(FromField, ToField). uuid-types is used because it contains fewer transitive dependencies, but uuid is used as a dependency for the test case.

This fixes #62.

@kmicklas
Copy link
Contributor

I'm somewhat concerned with this instance since it isn't really canonical. I've used orphan instances for UUID, except encoding to binary blobs instead of text for compactness, for example.

@mkoppmann
Copy link
Contributor Author

You’re right. That’s why I just copied what postgresql-simple did just to be consistent at least.
If this PR isn’t going to be merged, I will accept that of course and just continue to provide my own newtype wrapper in my codebase :)

@kmicklas
Copy link
Contributor

kmicklas commented Feb 5, 2021

What do you mean by consistent? Postgres has a native UUID type so it doesn't have to a make a choice between string/blob.

@mkoppmann
Copy link
Contributor Author

Oh, true. I now see the problem with this too. So either we choose a default instance and people who want a binary implementation have to use a newtype, or we don’t define an instance at all.

@danwdart
Copy link

Although it's less space-saving, I suspect that the text encoding is viewed as making more sense because it can be directly queried in a textual manner.

@malteneuss
Copy link

malteneuss commented Apr 19, 2025

Same as in #62:
As there are basically two valuable encodings (as binary BLOB for performance, and TEXT for human readability in e.g. CLI), would it be possible to add both encodings with BLOB as the default to be fast by default like Postgres and popular Rust libraries like rusqlite do, and a newtype wrapper like TextUUID for textual representations?

Having UUIDv7 soon in haskell-hvr/uuid#87 makes the UUID type even more appealing in databases so that out-of-the-box support would be great.

@mkoppmann mkoppmann closed this by deleting the head repository Jun 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add FromField instance for UUID
4 participants