Make sea-orm-cli & sea-orm-migration dependencies optional#2367
Conversation
|
@billy1624 could you allow CI checks, please? |
|
I've rebased the branch, probably some issues should be gone now. |
| DbBackend::MySql => MySql.query_tables(), | ||
| DbBackend::Postgres => Postgres.query_tables(), | ||
| DbBackend::Sqlite => Sqlite.query_tables(), |
There was a problem hiding this comment.
would something like this work?
#[cfg(feature = "sqlx-mysql")]
DbBackend::MySql => MySql.query_tables(),
#[cfg(feature = "sqlx-postgres")]
DbBackend::Postgres => Postgres.query_tables(),
#[cfg(feature = "sqlx-sqlite")]
DbBackend::Sqlite => Sqlite.query_tables(),if the feature is not enabled, the variant shouldn't exist
There was a problem hiding this comment.
Unfortunately not, as Rust needs the arms to be present. But the direction of thought is right, thank you
|
Ok, I've started testing against these two checks from the action scripts: cargo clippy --manifest-path sea-orm-migration/Cargo.toml -- -D warnings
cargo clippy --manifest-path sea-orm-migration/Cargo.toml --features sqlx-postgres -- -D warnings+on my personal project which uses the patched version [patch.crates-io]
sea-orm = { git = "https://github.com/xamgore/sea-orm.git", branch = "master" }
sea-orm-cli = { git = "https://github.com/xamgore/sea-orm.git", branch = "master" }
sea-orm-migration = { git = "https://github.com/xamgore/sea-orm.git", branch = "master" }It works. |
|
@tyt2y3 thanks for all your work on this crate, truly amazing! 😌 ❤️ |
🎉 Released In 1.1.12 🎉Thank you everyone for the contribution! |
Addresses #2320.
My team is working on a workspace project. To make sure generated models are always the same, we decided to make
sea-orm-clia member crate. You may find details at the discussion 1889.The problem is,
sea-orm-cli/codegenfeature imports all the database drivers, even thoughsqliteandmysqlrepresent zero interest for me.libsqlite-sys+sqlx-mysql+sqlx-sqlitetake quite a few seconds in total compilation time, and I believe this could be improved.I've gone through
dependency-hellfeature-shenanigans, but could easily make a mistake. So testing and merging this PR won't be easy. I tested the code on my local environment: tweaked all the possible combinations of features to see, whether the compiler would grumble. Also, I have patched my team project with local sea-orm codebase and tested it against it.