uuid-rs / uuid

Generate and parse UUIDs.

Home Page:https://www.crates.io/crates/uuid

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement sql trait

HumanG33k opened this issue · comments

I try to work with uuid and https://docs.rs/postgres/latest/postgres/
but i have an issue.

     result = row.get(0); 
                 ^^^ the trait `FromSql<'_>` is not implemented for `Uuid` 

It make sense and it can be fix with creating a trait or using str before but it can be great if it can be native.
But it may need sql stuff use by "all" crate.

Thanks for the suggestion @HumanG33k, we could consider adding unstable postgres support to uuid here (there's some prior art in the zerocopy feature), or the postgres crate could consider adding a uuid feature with FromSql support. The other alternative could be for you to wrap Uuid in your own newtype that you implement FromSql for:

PostgresUuid(Uuid);

The quickest path would probably be to use a newtype. Unstable features in uuid need some extra environment variables to be set, so aren't as user-friendly as other approaches.

Just coming back through some triage. It looks like there hasn't been any activity in a while here so I'll go ahead and close this one. Ideally the postgres crate would add a uuid feature that supported this, given PostgreSQL has a native UUID type that seems appropriate to me.