Skip to content

Commit

Permalink
Repair the main branch (#16)
Browse files Browse the repository at this point in the history
* Fix the features

* Make CI build all features

* Update ci

* Fix fmt

* Undo cargo fmt changes

* Specifcally test against pg

* Fix host

* Fix the book

* Repair the book

* Remove keeper tests from the book

* Fix examples

* Add the default

* Repair atmosphere
  • Loading branch information
mara-schulke authored Feb 13, 2024
1 parent 9a4300e commit 7c65b52
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
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

0 comments on commit 7c65b52

Please sign in to comment.