-
Notifications
You must be signed in to change notification settings - Fork 45
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
Comments
@vrom911 thanks for reporting. I'll take a look into it. |
The implementation is based on `postgresql-simple`[1][2]. `uuid-types`[3] is used because it contains fewer transitive dependencies, but `uuid`[4] is used as a dependency for the test case. This fixes nurpax#62. [1]: https://hackage.haskell.org/package/postgresql-simple-0.5.3.0/docs/Database-PostgreSQL-Simple-FromField.html#t:FromField [2]: https://hackage.haskell.org/package/postgresql-simple-0.6.2/docs/Database-PostgreSQL-Simple-ToField.html#t:ToField [3]: https://hackage.haskell.org/package/uuid-types-1.0.3 [4]: https://hackage.haskell.org/package/uuid
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. |
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... |
postgresql-simple
contains such instance. It would be really helpful to have it here as well.The text was updated successfully, but these errors were encountered: