-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Possibility to build sqlx without runtime #1627
Comments
Create 3 corresponding features like: You can see how it's done in sea-orm: https://github.com/SeaQL/sea-orm/blob/master/Cargo.toml |
Yeah, but do crate that only needs derives really need to advertise flags to match the chosen runtime? |
TLDRLarger projects may need to split db-related stuff into multiple crates and ability to compile without runtime would simplify that use case. See use cases and longer summary below: Crate with shared data typesI have a crate that defines shared data types for multi-crate project. Different downstream crates will use the data types in different ways - some with db-related stuff, some without (yes, there is pub enum State {
Pass = 1,
Fail = 2,
Skip = 3,
....
}
#[cfg(feature="postgres")]
mod postgres {
impl Encode<'_, Postgres> for super::State {
...
}
impl Decode<'_, Postgres> for super::State {
...
}
impl Type<Postgres> for super::State {
...
}
} On this level, the crate does not need to select runtime. It does not even know which runtime will be used by downstream crate. The easiest solution is to 'just select runtime', but wrong selection can result in two or more crates selecting different runtime and conflict on compilation. (or just compile bunch of dead code, I did not experiment to much with actual setup). Crate with db access layerSimilar case as above. I have a crate that implements a report on database. It will consist of input/output data types, some database queries. But again, it will not run those queries itself. The sole use is to be included in downstream crate that will start runtime and use shared access layer definition to run them. If I try to do something like that, I will again end with same issue as in the first case. Solution from
|
I have the exact use case @heroin-moose and @zdenek-crha describe where I have a bunch of types in one crate and want to derive |
This is fixed in the 0.7.0 release which is currently in an alpha cycle. |
Currently sqlx requires one of the runtime-* features enabled. However, when using sqlx in a crate that only defines types and derives FromRow it may be a little problematic, because crate users can have different runtimes.
The text was updated successfully, but these errors were encountered: