Problem
PR #108 updates the sqlx requirement from 0.8 to 0.9, but SQLx 0.9 removed the combined runtime/TLS feature names currently used by this crate.
Changing only:
sqlx = { version = "0.9", default-features = false, features = ["macros"] }
fails dependency resolution with errors such as:
package `sqlx-adapter` depends on `sqlx` with feature
`runtime-async-std-native-tls` but `sqlx` does not have that feature
Proposed changes
Keep the existing public feature names for downstream compatibility, but map them to SQLx 0.9 features:
runtime-async-std-native-tls = [
"casbin/runtime-async-std",
"sqlx/runtime-async-std",
"sqlx/tls-native-tls",
]
runtime-async-std-rustls = [
"casbin/runtime-async-std",
"sqlx/runtime-async-std",
"sqlx/tls-rustls",
]
runtime-tokio = [
"casbin/runtime-tokio",
"sqlx/runtime-tokio",
]
runtime-tokio-native-tls = [
"casbin/runtime-tokio",
"sqlx/runtime-tokio",
"sqlx/tls-native-tls",
]
runtime-tokio-rustls = [
"casbin/runtime-tokio",
"sqlx/runtime-tokio",
"sqlx/tls-rustls",
]
The upgrade is also an opportunity to remove unused direct dependencies:
- The optional
tokio and async-std dependencies are not enabled by the crate's runtime features, and production code does not use them directly. The dev-dependencies are sufficient for the test macros.
dotenvy is only used by SqlxAdapter::new() to call dotenv().ok(). The adapter already receives a complete database URL, so loading the caller's .env is an unnecessary hidden side effect.
The plain runtime-tokio feature should also attach the existing Tokio tests. Currently, only the TLS variants receive #[tokio::test].
Acceptance criteria
- PostgreSQL builds with Tokio and async-std.
- Native TLS and rustls variants compile.
runtime-tokio without a TLS backend runs the existing tests.
SqlxAdapter::new_with_pool(pool.clone()) accepts a SQLx 0.9 pool.
- Policies saved through a shared pool can be loaded by another adapter/Enforcer using the same pool.
- Existing policy add/remove tests continue to pass.
- SQLx 0.9 offline metadata is generated for PostgreSQL, MySQL, and SQLite.
- A downstream application using SQLx 0.9 resolves one SQLx version rather than both 0.8 and 0.9.
Related: #108, #109.
Problem
PR #108 updates the
sqlxrequirement from 0.8 to 0.9, but SQLx 0.9 removed the combined runtime/TLS feature names currently used by this crate.Changing only:
fails dependency resolution with errors such as:
Proposed changes
Keep the existing public feature names for downstream compatibility, but map them to SQLx 0.9 features:
The upgrade is also an opportunity to remove unused direct dependencies:
tokioandasync-stddependencies are not enabled by the crate's runtime features, and production code does not use them directly. The dev-dependencies are sufficient for the test macros.dotenvyis only used bySqlxAdapter::new()to calldotenv().ok(). The adapter already receives a complete database URL, so loading the caller's.envis an unnecessary hidden side effect.The plain
runtime-tokiofeature should also attach the existing Tokio tests. Currently, only the TLS variants receive#[tokio::test].Acceptance criteria
runtime-tokiowithout a TLS backend runs the existing tests.SqlxAdapter::new_with_pool(pool.clone())accepts a SQLx 0.9 pool.Related: #108, #109.