Skip to content
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

Repair the main branch #16

Merged
merged 14 commits into from
Feb 13, 2024
8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ sqlx.workspace = true

[features]
default = []
mysql = ["atmosphere-core/mysql"]
postgres = ["atmosphere-core/postgres"]
sqlite = ["atmosphere-core/sqlite"]
mysql = ["atmosphere-core/mysql", "atmosphere-macros/mysql"]
postgres = ["atmosphere-core/postgres", "atmosphere-macros/postgres"]
sqlite = ["atmosphere-core/sqlite", "atmosphere-macros/sqlite"]

[dev-dependencies]
sqlx = { version = "0.7", features = ["runtime-tokio-rustls", "any", "sqlite", "mysql", "postgres"] }
Expand All @@ -53,10 +53,12 @@ tokio-test = "0"
[[example]]
name = "forest"
path = "examples/forest/main.rs"
required-features = ["sqlite"]

[[example]]
name = "blog"
path = "examples/blog/main.rs"
required-features = ["sqlite"]

[[test]]
name = "integration"
Expand Down
14 changes: 1 addition & 13 deletions atmosphere-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@ pub mod driver {
))]
compile_error!("only one database driver can be set – please use multiple binaries using different atmosphere features if you need more than one database");

#[cfg(all(
not(feature = "mysql"),
not(feature = "postgres"),
not(feature = "sqlite")
))]
/// Atmosphere Database Driver
pub type Driver = sqlx::Any;

#[cfg(all(feature = "postgres", not(any(feature = "mysql", feature = "sqlite"))))]
/// Atmosphere Database Driver
pub type Driver = sqlx::Postgres;
Expand All @@ -104,11 +96,7 @@ pub mod driver {
/// Atmosphere Database Pool
pub type Pool = sqlx::SqlitePool;

#[cfg(all(
not(feature = "postgres"),
not(feature = "mysql"),
not(feature = "sqlite")
))]
#[cfg(not(any(feature = "postgres", feature = "mysql", feature = "sqlite")))]
compile_error!(
"you must chose a atmosphere database driver (available: postgres, mysql, sqlite)"
);
Expand Down
6 changes: 6 additions & 0 deletions atmosphere-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,11 @@ syn = { version = "2.0.39", default-features = false, features = ["parsing", "pr
quote = { version = "1.0.14", default-features = false }
lazy_static = "1.4.0"

[features]
default = []
mysql = ["atmosphere-core/mysql"]
postgres = ["atmosphere-core/postgres"]
sqlite = ["atmosphere-core/sqlite"]

[dev-dependencies]
chrono = "0.4.31"
5 changes: 4 additions & 1 deletion examples/blog/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ struct Post {

#[tokio::main]
async fn main() -> atmosphere::Result<()> {
let pool = Pool::connect(&std::env::var("DATABASE_URL").unwrap())
let pool = Pool::connect(":memory:").await.unwrap();

sqlx::migrate!("examples/blog/migrations")
.run(&pool)
.await
.unwrap();

Expand Down
5 changes: 4 additions & 1 deletion examples/forest/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ struct Tree {

#[tokio::main]
async fn main() -> atmosphere::Result<()> {
let pool = Pool::connect(&std::env::var("DATABASE_URL").unwrap())
let pool = Pool::connect(":memory:").await.unwrap();

sqlx::migrate!("examples/forest/migrations")
.run(&pool)
.await
.unwrap();

Expand Down
Loading