diesel: the trait bound uuid::Uuid: diesel::Expression is not satisfied
Versions
- Rust: 1.42.0
- Diesel: 1.4.4
- Database: Postgres 12
- Operating System: Win 10
Cargo.toml
diesel = { version = "=1.4.4", features = ["postgres", "r2d2", "uuid", "chrono"] }
diesel_migrations = "=1.4.0"
...
uuid = { version = "=0.8.1", features = ["serde", "v4"] }
Problem Description
What are you trying to accomplish?
Use uuid with diesel with no problems.
What is the expected output?
It works.
What is the actual output?
the trait bound uuid::Uuid: diesel::Expression is not satisfied
Are you seeing any additional errors?
Nope.
I saw:
But still problems, why?
Checklist
- I have already looked over the issue tracker for similar issues.
- This issue can be reproduced on Rust’s stable channel. (Your issue will be closed if this is not the case)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 26 (9 by maintainers)
Second @problame’s issue, the following dependencies and features don’t work:
But this does:
Basically a duplicate of https://github.com/diesel-rs/diesel/issues/1900.
(You need to use the
uuidv07feature to make this work.)FWIW, I am using diesel 1.4.5 with uuid 0.8.1 and adding the
uuidv07feature just fixed the problem for me. Is there a cfg! in diesel 1.4.5 that still usesuuidv07?@KodrAus Thanks for reaching out here ❤️ There are a few common uuid related issues in diesel:
diesel::sql_types::Uuidanduuid::Uuid. This is basically an issue with users ignoring our documentation, which explicitly states that types fromdiesel::sql_typescannot hold values and shouldn’t be used anywhere in your “model”. This is something that we can only improve on diesels side.uuid< 0.7 and the later for the 0.7 and 0.8 releases. As of today I personally believe it was a mistake to name that features that way, but unfortunately there is no way to reverse that. Fortunately, the next diesel release will be 2.0, so we can fix that there. It’s already better on the master branch, where we’ve just dropped support for uuid < 0.7 and only have single uuid feature left. Maybe I will also rename the features for third party crates to indicate the version numbers in a better way, so that this does not happen anymore. So in the end, again that’s something to fix on diesels side.That written: The uuid integration in diesel is really simple, as it’s only a few lines of code. As long as the two function we are using are not changed in an incompatible way there is really not much maintained burden here. Having a stable uuid 1.0 release should really help there.
@CuriousCI We don’t plan to release any additional 1.4.x release at this point in time as we just don’t have the resources to maintain more than one diesel version in parallel.
Shouldn’t the
1.4.xrelease supportuuid 1.0.0too? I’m currently facing some issues with Rocket.rs as it relies on diesel 1.4, but it’s uuid feature is implemented foruuid 1.0.0. I’ll open an issue to add2.0.0support for diesel in Rocket, but until then I have to monkey patch the problem: I downgraded touuid 0.8, and manually implemented Rocket’s traits.@KodrAus Thanks for the heads up. I’ve pushed https://github.com/diesel-rs/diesel/pull/3137 to add support for uuid 1.0.0 to diesel master 🎉
Just a heads up @weiznich I’m running through that
1.0.0release ofuuidnow: https://github.com/uuid-rs/uuid/pull/596@KodrAus Thanks for that information. Yes that’s the plan to update the dependency to
1.0before doing the diesel 2.0 release.Thanks for the details @weiznich!
Yeh, there’s no way those
Uuid::from_fieldsandUuid::as_byteswill ever change. So your next release is going to be2.0? Depending on how you want to go, if you wanted to consolidate youruuidfeatures to just its1.0you should be safe depending onuuid’s1.0.0-alpha.1release. We’re treating it as already stable, and will follow up with a1.0.0proper once it’s proven itself. Cargo should happily consider1.0.0-alpha.1and1.0.0as semver compatible.I’m getting the trait ‘diesel::Expression’ is not implemented for ‘uuid::Uuid’ on 1.4.8 and uuid 8.2 with feature uuid in diesel.
Is there a trait impl we could add over in
uuidthat would clear all this up? We’re currently working on stabilizinguuidso hopefully can smooth things out fordieselone way or another.tl;dr Well, I used
uuid::Uuid, instead ofdiesel::sql_type::uuid, which quenched this error.More background: Unfortunately, none works for me. Here is my
Cargo.toml.The error reads:
Here is where went wrong:
In the issue tracker of whichever tool is giving you this warning. So if it’s cargo itself then here: https://github.com/rust-lang/cargo/, if it’s some custom subcommand in then in their issue tracker.