Skip to content

Commit dd47093

Browse files
committed
chore(test::custom_model_and_schema_path): actually use correct output path
it seems like the wrong one was used sicne the beginning
1 parent d6bec5c commit dd47093

File tree

8 files changed

+19
-203
lines changed

8 files changed

+19
-203
lines changed

test/custom_model_and_schema_path/data/models/table_a/generated.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22

33
use crate::diesel::*;
44
use crate::data::schema::*;
5-
use diesel::QueryResult;
65

7-
pub type ConnectionType = diesel::prelude::PgConnection;
6+
pub type ConnectionType = diesel::r2d2::PooledConnection<diesel::r2d2::ConnectionManager<diesel::pg::PgConnection>>;
87

98
/// Struct representing a row in table `tableA`
10-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName)]
9+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, diesel::Queryable, diesel::Selectable, diesel::QueryableByName)]
1110
#[diesel(table_name=tableA, primary_key(_id))]
1211
pub struct TableA {
1312
/// Field representing column `_id`
1413
pub _id: i32,
1514
}
1615

1716
/// Create Struct for a row in table `tableA` for [`TableA`]
18-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Insertable)]
17+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, diesel::Insertable)]
1918
#[diesel(table_name=tableA)]
2019
pub struct CreateTableA {
2120
/// Field representing column `_id`
@@ -39,21 +38,21 @@ pub struct PaginationResult<T> {
3938

4039
impl TableA {
4140
/// Insert a new row into `tableA` with a given [`CreateTableA`]
42-
pub fn create(db: &mut ConnectionType, item: &CreateTableA) -> QueryResult<Self> {
41+
pub fn create(db: &mut ConnectionType, item: &CreateTableA) -> diesel::QueryResult<Self> {
4342
use crate::data::schema::tableA::dsl::*;
4443

45-
insert_into(tableA).values(item).get_result::<Self>(db)
44+
diesel::insert_into(tableA).values(item).get_result::<Self>(db)
4645
}
4746

4847
/// Get a row from `tableA`, identified by the primary key
49-
pub fn read(db: &mut ConnectionType, param__id: i32) -> QueryResult<Self> {
48+
pub fn read(db: &mut ConnectionType, param__id: i32) -> diesel::QueryResult<Self> {
5049
use crate::data::schema::tableA::dsl::*;
5150

5251
tableA.filter(_id.eq(param__id)).first::<Self>(db)
5352
}
5453

5554
/// Paginates through the table where page is a 0-based index (i.e. page 0 is the first page)
56-
pub fn paginate(db: &mut ConnectionType, page: i64, page_size: i64) -> QueryResult<PaginationResult<Self>> {
55+
pub fn paginate(db: &mut ConnectionType, page: i64, page_size: i64) -> diesel::QueryResult<PaginationResult<Self>> {
5756
use crate::data::schema::tableA::dsl::*;
5857

5958
let page_size = if page_size < 1 { 1 } else { page_size };
@@ -71,7 +70,7 @@ impl TableA {
7170
}
7271

7372
/// Delete a row in `tableA`, identified by the primary key
74-
pub fn delete(db: &mut ConnectionType, param__id: i32) -> QueryResult<usize> {
73+
pub fn delete(db: &mut ConnectionType, param__id: i32) -> diesel::QueryResult<usize> {
7574
use crate::data::schema::tableA::dsl::*;
7675

7776
diesel::delete(tableA.filter(_id.eq(param__id))).execute(db)

test/custom_model_and_schema_path/data/models/table_b/generated.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
use crate::diesel::*;
44
use crate::data::models::table_a::TableA;
55
use crate::data::schema::*;
6-
use diesel::QueryResult;
76

8-
pub type ConnectionType = diesel::prelude::PgConnection;
7+
pub type ConnectionType = diesel::r2d2::PooledConnection<diesel::r2d2::ConnectionManager<diesel::pg::PgConnection>>;
98

109
/// Struct representing a row in table `tableB`
11-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Queryable, Selectable, QueryableByName, Associations, Identifiable)]
10+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, diesel::Queryable, diesel::Selectable, diesel::QueryableByName, diesel::Associations, diesel::Identifiable)]
1211
#[diesel(table_name=tableB, primary_key(_id), belongs_to(TableA, foreign_key=link))]
1312
pub struct TableB {
1413
/// Field representing column `_id`
@@ -18,7 +17,7 @@ pub struct TableB {
1817
}
1918

2019
/// Create Struct for a row in table `tableB` for [`TableB`]
21-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Insertable)]
20+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, diesel::Insertable)]
2221
#[diesel(table_name=tableB)]
2322
pub struct CreateTableB {
2423
/// Field representing column `_id`
@@ -28,7 +27,7 @@ pub struct CreateTableB {
2827
}
2928

3029
/// Update Struct for a row in table `tableB` for [`TableB`]
31-
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, AsChangeset, PartialEq, Default)]
30+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, diesel::AsChangeset, PartialEq, Default)]
3231
#[diesel(table_name=tableB)]
3332
pub struct UpdateTableB {
3433
/// Field representing column `link`
@@ -52,21 +51,21 @@ pub struct PaginationResult<T> {
5251

5352
impl TableB {
5453
/// Insert a new row into `tableB` with a given [`CreateTableB`]
55-
pub fn create(db: &mut ConnectionType, item: &CreateTableB) -> QueryResult<Self> {
54+
pub fn create(db: &mut ConnectionType, item: &CreateTableB) -> diesel::QueryResult<Self> {
5655
use crate::data::schema::tableB::dsl::*;
5756

58-
insert_into(tableB).values(item).get_result::<Self>(db)
57+
diesel::insert_into(tableB).values(item).get_result::<Self>(db)
5958
}
6059

6160
/// Get a row from `tableB`, identified by the primary key
62-
pub fn read(db: &mut ConnectionType, param__id: i32) -> QueryResult<Self> {
61+
pub fn read(db: &mut ConnectionType, param__id: i32) -> diesel::QueryResult<Self> {
6362
use crate::data::schema::tableB::dsl::*;
6463

6564
tableB.filter(_id.eq(param__id)).first::<Self>(db)
6665
}
6766

6867
/// Paginates through the table where page is a 0-based index (i.e. page 0 is the first page)
69-
pub fn paginate(db: &mut ConnectionType, page: i64, page_size: i64) -> QueryResult<PaginationResult<Self>> {
68+
pub fn paginate(db: &mut ConnectionType, page: i64, page_size: i64) -> diesel::QueryResult<PaginationResult<Self>> {
7069
use crate::data::schema::tableB::dsl::*;
7170

7271
let page_size = if page_size < 1 { 1 } else { page_size };
@@ -84,14 +83,14 @@ impl TableB {
8483
}
8584

8685
/// Update a row in `tableB`, identified by the primary key with [`UpdateTableB`]
87-
pub fn update(db: &mut ConnectionType, param__id: i32, item: &UpdateTableB) -> QueryResult<Self> {
86+
pub fn update(db: &mut ConnectionType, param__id: i32, item: &UpdateTableB) -> diesel::QueryResult<Self> {
8887
use crate::data::schema::tableB::dsl::*;
8988

9089
diesel::update(tableB.filter(_id.eq(param__id))).set(item).get_result(db)
9190
}
9291

9392
/// Delete a row in `tableB`, identified by the primary key
94-
pub fn delete(db: &mut ConnectionType, param__id: i32) -> QueryResult<usize> {
93+
pub fn delete(db: &mut ConnectionType, param__id: i32) -> diesel::QueryResult<usize> {
9594
use crate::data::schema::tableB::dsl::*;
9695

9796
diesel::delete(tableB.filter(_id.eq(param__id))).execute(db)

test/custom_model_and_schema_path/models/mod.rs

Lines changed: 0 additions & 2 deletions
This file was deleted.

test/custom_model_and_schema_path/models/table_a/generated.rs

Lines changed: 0 additions & 78 deletions
This file was deleted.

test/custom_model_and_schema_path/models/table_a/mod.rs

Lines changed: 0 additions & 2 deletions
This file was deleted.

test/custom_model_and_schema_path/models/table_b/generated.rs

Lines changed: 0 additions & 98 deletions
This file was deleted.

test/custom_model_and_schema_path/models/table_b/mod.rs

Lines changed: 0 additions & 2 deletions
This file was deleted.

test/custom_model_and_schema_path/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
55
cd $SCRIPT_DIR
66

77
cargo run --manifest-path ../../Cargo.toml -- \
8-
-i data/schema.rs -o models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection<diesel::r2d2::ConnectionManager<diesel::pg::PgConnection>>" --schema-path "crate::data::schema::" --model-path "crate::data::models::"
8+
-i data/schema.rs -o data/models -g id -g created_at -g updated_at -c "diesel::r2d2::PooledConnection<diesel::r2d2::ConnectionManager<diesel::pg::PgConnection>>" --schema-path "crate::data::schema::" --model-path "crate::data::models::"

0 commit comments

Comments
 (0)