Skip to content

Commit

Permalink
test: change "single_model_file" to be compile-able
Browse files Browse the repository at this point in the history
  • Loading branch information
hasezoey committed Nov 2, 2023
1 parent 3b1dbf5 commit 1a31a2e
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 3 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ members = [
"test/simple_table_mysql",
"test/simple_table_sqlite",
"test/custom_model_and_schema_path",
"test/single_model_file",
]
resolver = "2"
16 changes: 16 additions & 0 deletions test/single_model_file/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[lib]
path = "lib.rs"

[package]
name = "single_model_file"
version = "0.1.0"
edition = "2021"

[dependencies]
diesel = { version = "*", default-features = false, features = [
"postgres",
"chrono",
] }
dsync = { path = "../../" }
chrono = { version = "*", features = ["serde"] }
serde = { version = "*", features = ["derive"] }
2 changes: 2 additions & 0 deletions test/single_model_file/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod models;
pub mod schema;
2 changes: 1 addition & 1 deletion test/single_model_file/models/table1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use diesel::*;
use crate::schema::*;
use diesel::QueryResult;

pub type ConnectionType = diesel::r2d2::PooledConnection<diesel::r2d2::ConnectionManager<diesel::prelude::PgConnection>>;
pub type ConnectionType = diesel::prelude::PgConnection;

/// Struct representing a row in table `table1`
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable)]
Expand Down
2 changes: 1 addition & 1 deletion test/single_model_file/models/table2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use diesel::*;
use crate::schema::*;
use diesel::QueryResult;

pub type ConnectionType = diesel::r2d2::PooledConnection<diesel::r2d2::ConnectionManager<diesel::prelude::PgConnection>>;
pub type ConnectionType = diesel::prelude::PgConnection;

/// Struct representing a row in table `table2`
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable)]
Expand Down
3 changes: 2 additions & 1 deletion test/single_model_file/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

cd $SCRIPT_DIR

cargo run -- -i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection<diesel::r2d2::ConnectionManager<diesel::prelude::PgConnection>>" --single-model-file
cargo run --manifest-path ../../Cargo.toml -- \
-i schema.rs -o models -g id -g created_at -g updated_at -c "diesel::prelude::PgConnection" --single-model-file

0 comments on commit 1a31a2e

Please sign in to comment.