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

Add FromField instance for UUID #62

Open
vrom911 opened this issue May 16, 2018 · 3 comments · May be fixed by #89
Open

Add FromField instance for UUID #62

vrom911 opened this issue May 16, 2018 · 3 comments · May be fixed by #89
Assignees

Comments

@vrom911
Copy link
Contributor

vrom911 commented May 16, 2018

postgresql-simple contains such instance. It would be really helpful to have it here as well.

@sigrlami
Copy link
Collaborator

@vrom911 thanks for reporting. I'll take a look into it.

@sigrlami sigrlami self-assigned this Jan 28, 2020
mkoppmann added a commit to mkoppmann/sqlite-simple that referenced this issue Oct 25, 2020
@mkoppmann mkoppmann linked a pull request Oct 25, 2020 that will close this issue
@kmicklas
Copy link
Contributor

Postgres supports UUIDs as a native type, so there is a canonical encoding. SQLite doesn't, so we'd have to decide whether to encode them via the text representation of more compactly as binary blobs. Neither way is going to be best for all use cases.

@danwdart
Copy link

danwdart commented Oct 10, 2022

I've been using this locally, and I can make it a "pivot" package with only instances, if there's interest:

instance FromField UUID where
    fromField f@(Field (SQLText txt) _) = case fromText txt of
        Just r  -> Ok r
        Nothing -> returnError ConversionFailed f "need a uuid"
    fromField f = returnError ConversionFailed f "need a uuid"

instance ToField UUID where
    toField = SQLText . toText

Or I can pluck the code from #89...

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

Successfully merging a pull request may close this issue.

4 participants