From 20cf314b5eb4315bb816229a7d1082c4012ebbf7 Mon Sep 17 00:00:00 2001 From: hasezoey Date: Thu, 24 Aug 2023 11:20:51 +0200 Subject: [PATCH] fix(code): rename "type Connection" to "type ConnectionType" to lessen conflicts with diesel's "Connection" trait --- src/code.rs | 14 +++++++------- test/autogenerated_all/models/todos/generated.rs | 12 ++++++------ .../models/todos/generated.rs | 12 ++++++------ .../models/todos/generated.rs | 12 ++++++------ .../models/todos/generated.rs | 12 ++++++------ .../models/tableA/generated.rs | 10 +++++----- .../models/tableB/generated.rs | 12 ++++++------ test/custom_model_path/models/tableA/generated.rs | 10 +++++----- test/custom_model_path/models/tableB/generated.rs | 12 ++++++------ test/manual_primary_keys/models/todos/generated.rs | 10 +++++----- .../models/users/generated.rs | 12 ++++++------ test/simple_table/models/todos/generated.rs | 12 ++++++------ test/simple_table_async/models/todos/generated.rs | 12 ++++++------ .../models/todos/generated.rs | 12 ++++++------ .../models/todos/generated.rs | 12 ++++++------ test/use_statements/models/fang_tasks/generated.rs | 12 ++++++------ 16 files changed, 94 insertions(+), 94 deletions(-) diff --git a/src/code.rs b/src/code.rs index d7987382..c5715752 100644 --- a/src/code.rs +++ b/src/code.rs @@ -370,7 +370,7 @@ impl {struct_name} {{ if create_struct.has_fields() { buffer.push_str(&format!( r##" - pub{async_keyword} fn create(db: &mut Connection, item: &{create_struct_identifier}) -> QueryResult {{ + pub{async_keyword} fn create(db: &mut ConnectionType, item: &{create_struct_identifier}) -> QueryResult {{ use {schema_path}{table_name}::dsl::*; insert_into({table_name}).values(item).get_result::(db){await_keyword} @@ -380,7 +380,7 @@ impl {struct_name} {{ } else { buffer.push_str(&format!( r##" - pub{async_keyword} fn create(db: &mut Connection) -> QueryResult {{ + pub{async_keyword} fn create(db: &mut ConnectionType) -> QueryResult {{ use {schema_path}{table_name}::dsl::*; insert_into({table_name}).default_values().get_result::(db){await_keyword} @@ -391,7 +391,7 @@ impl {struct_name} {{ buffer.push_str(&format!( r##" - pub{async_keyword} fn read(db: &mut Connection, {item_id_params}) -> QueryResult {{ + pub{async_keyword} fn read(db: &mut ConnectionType, {item_id_params}) -> QueryResult {{ use {schema_path}{table_name}::dsl::*; {table_name}.{item_id_filters}.first::(db){await_keyword} @@ -401,7 +401,7 @@ impl {struct_name} {{ buffer.push_str(&format!(r##" /// Paginates through the table where page is a 0-based index (i.e. page 0 is the first page) - pub{async_keyword} fn paginate(db: &mut Connection, page: i64, page_size: i64) -> QueryResult> {{ + pub{async_keyword} fn paginate(db: &mut ConnectionType, page: i64, page_size: i64) -> QueryResult> {{ use {schema_path}{table_name}::dsl::*; let page_size = if page_size < 1 {{ 1 }} else {{ page_size }}; @@ -429,7 +429,7 @@ impl {struct_name} {{ // we should generate an update() method. buffer.push_str(&format!(r##" - pub{async_keyword} fn update(db: &mut Connection, {item_id_params}, item: &{update_struct_identifier}) -> QueryResult {{ + pub{async_keyword} fn update(db: &mut ConnectionType, {item_id_params}, item: &{update_struct_identifier}) -> QueryResult {{ use {schema_path}{table_name}::dsl::*; diesel::update({table_name}.{item_id_filters}).set(item).get_result(db){await_keyword} @@ -439,7 +439,7 @@ impl {struct_name} {{ buffer.push_str(&format!( r##" - pub{async_keyword} fn delete(db: &mut Connection, {item_id_params}) -> QueryResult {{ + pub{async_keyword} fn delete(db: &mut ConnectionType, {item_id_params}) -> QueryResult {{ use {schema_path}{table_name}::dsl::*; diesel::delete({table_name}.{item_id_filters}).execute(db){await_keyword} @@ -496,7 +496,7 @@ fn build_imports(table: &ParsedTableMacro, config: &GenerationConfig) -> String let connection_type_alias = if table_options.get_fns() { format!( - "\ntype Connection = {connection_type};", + "\ntype ConnectionType = {connection_type};", connection_type = config.connection_type, ) } else { diff --git a/test/autogenerated_all/models/todos/generated.rs b/test/autogenerated_all/models/todos/generated.rs index 6a5928ce..b03ab0fd 100644 --- a/test/autogenerated_all/models/todos/generated.rs +++ b/test/autogenerated_all/models/todos/generated.rs @@ -6,7 +6,7 @@ use diesel::QueryResult; use serde::{Deserialize, Serialize}; -type Connection = diesel::r2d2::PooledConnection>; +type ConnectionType = diesel::r2d2::PooledConnection>; #[derive(Debug, Serialize, Deserialize, Clone, Queryable, Insertable, AsChangeset, Selectable)] #[diesel(table_name=todos, primary_key(id))] @@ -35,20 +35,20 @@ pub struct PaginationResult { impl Todo { - pub fn create(db: &mut Connection) -> QueryResult { + pub fn create(db: &mut ConnectionType) -> QueryResult { use crate::schema::todos::dsl::*; insert_into(todos).default_values().get_result::(db) } - pub fn read(db: &mut Connection, param_id: i32) -> QueryResult { + pub fn read(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::schema::todos::dsl::*; todos.filter(id.eq(param_id)).first::(db) } /// Paginates through the table where page is a 0-based index (i.e. page 0 is the first page) - pub fn paginate(db: &mut Connection, page: i64, page_size: i64) -> QueryResult> { + pub fn paginate(db: &mut ConnectionType, page: i64, page_size: i64) -> QueryResult> { use crate::schema::todos::dsl::*; let page_size = if page_size < 1 { 1 } else { page_size }; @@ -65,13 +65,13 @@ impl Todo { }) } - pub fn update(db: &mut Connection, param_id: i32, item: &UpdateTodo) -> QueryResult { + pub fn update(db: &mut ConnectionType, param_id: i32, item: &UpdateTodo) -> QueryResult { use crate::schema::todos::dsl::*; diesel::update(todos.filter(id.eq(param_id))).set(item).get_result(db) } - pub fn delete(db: &mut Connection, param_id: i32) -> QueryResult { + pub fn delete(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::schema::todos::dsl::*; diesel::delete(todos.filter(id.eq(param_id))).execute(db) diff --git a/test/autogenerated_attributes/models/todos/generated.rs b/test/autogenerated_attributes/models/todos/generated.rs index 430db3a1..13a90827 100644 --- a/test/autogenerated_attributes/models/todos/generated.rs +++ b/test/autogenerated_attributes/models/todos/generated.rs @@ -6,7 +6,7 @@ use diesel::QueryResult; use serde::{Deserialize, Serialize}; -type Connection = diesel::r2d2::PooledConnection>; +type ConnectionType = diesel::r2d2::PooledConnection>; #[derive(Debug, Serialize, Deserialize, Clone, Queryable, Insertable, AsChangeset, Selectable)] #[diesel(table_name=todos, primary_key(id))] @@ -40,20 +40,20 @@ pub struct PaginationResult { impl Todo { - pub fn create(db: &mut Connection, item: &CreateTodo) -> QueryResult { + pub fn create(db: &mut ConnectionType, item: &CreateTodo) -> QueryResult { use crate::schema::todos::dsl::*; insert_into(todos).values(item).get_result::(db) } - pub fn read(db: &mut Connection, param_id: i32) -> QueryResult { + pub fn read(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::schema::todos::dsl::*; todos.filter(id.eq(param_id)).first::(db) } /// Paginates through the table where page is a 0-based index (i.e. page 0 is the first page) - pub fn paginate(db: &mut Connection, page: i64, page_size: i64) -> QueryResult> { + pub fn paginate(db: &mut ConnectionType, page: i64, page_size: i64) -> QueryResult> { use crate::schema::todos::dsl::*; let page_size = if page_size < 1 { 1 } else { page_size }; @@ -70,13 +70,13 @@ impl Todo { }) } - pub fn update(db: &mut Connection, param_id: i32, item: &UpdateTodo) -> QueryResult { + pub fn update(db: &mut ConnectionType, param_id: i32, item: &UpdateTodo) -> QueryResult { use crate::schema::todos::dsl::*; diesel::update(todos.filter(id.eq(param_id))).set(item).get_result(db) } - pub fn delete(db: &mut Connection, param_id: i32) -> QueryResult { + pub fn delete(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::schema::todos::dsl::*; diesel::delete(todos.filter(id.eq(param_id))).execute(db) diff --git a/test/autogenerated_primary_keys/models/todos/generated.rs b/test/autogenerated_primary_keys/models/todos/generated.rs index e81f022c..5e35c896 100644 --- a/test/autogenerated_primary_keys/models/todos/generated.rs +++ b/test/autogenerated_primary_keys/models/todos/generated.rs @@ -6,7 +6,7 @@ use diesel::QueryResult; use serde::{Deserialize, Serialize}; -type Connection = diesel::r2d2::PooledConnection>; +type ConnectionType = diesel::r2d2::PooledConnection>; #[derive(Debug, Serialize, Deserialize, Clone, Queryable, Insertable, AsChangeset, Selectable)] #[diesel(table_name=todos, primary_key(id))] @@ -40,20 +40,20 @@ pub struct PaginationResult { impl Todo { - pub fn create(db: &mut Connection, item: &CreateTodo) -> QueryResult { + pub fn create(db: &mut ConnectionType, item: &CreateTodo) -> QueryResult { use crate::schema::todos::dsl::*; insert_into(todos).values(item).get_result::(db) } - pub fn read(db: &mut Connection, param_id: i32) -> QueryResult { + pub fn read(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::schema::todos::dsl::*; todos.filter(id.eq(param_id)).first::(db) } /// Paginates through the table where page is a 0-based index (i.e. page 0 is the first page) - pub fn paginate(db: &mut Connection, page: i64, page_size: i64) -> QueryResult> { + pub fn paginate(db: &mut ConnectionType, page: i64, page_size: i64) -> QueryResult> { use crate::schema::todos::dsl::*; let page_size = if page_size < 1 { 1 } else { page_size }; @@ -70,13 +70,13 @@ impl Todo { }) } - pub fn update(db: &mut Connection, param_id: i32, item: &UpdateTodo) -> QueryResult { + pub fn update(db: &mut ConnectionType, param_id: i32, item: &UpdateTodo) -> QueryResult { use crate::schema::todos::dsl::*; diesel::update(todos.filter(id.eq(param_id))).set(item).get_result(db) } - pub fn delete(db: &mut Connection, param_id: i32) -> QueryResult { + pub fn delete(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::schema::todos::dsl::*; diesel::delete(todos.filter(id.eq(param_id))).execute(db) diff --git a/test/cleanup_generated_content/models/todos/generated.rs b/test/cleanup_generated_content/models/todos/generated.rs index 6f4ce713..a1080c5f 100644 --- a/test/cleanup_generated_content/models/todos/generated.rs +++ b/test/cleanup_generated_content/models/todos/generated.rs @@ -6,7 +6,7 @@ use diesel::QueryResult; use serde::{Deserialize, Serialize}; -type Connection = diesel::r2d2::PooledConnection>; +type ConnectionType = diesel::r2d2::PooledConnection>; #[derive(Debug, Serialize, Deserialize, Clone, Queryable, Insertable, AsChangeset, Selectable)] #[diesel(table_name=todos, primary_key(id))] @@ -48,20 +48,20 @@ pub struct PaginationResult { impl Todo { - pub fn create(db: &mut Connection, item: &CreateTodo) -> QueryResult { + pub fn create(db: &mut ConnectionType, item: &CreateTodo) -> QueryResult { use crate::schema::todos::dsl::*; insert_into(todos).values(item).get_result::(db) } - pub fn read(db: &mut Connection, param_id: i32) -> QueryResult { + pub fn read(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::schema::todos::dsl::*; todos.filter(id.eq(param_id)).first::(db) } /// Paginates through the table where page is a 0-based index (i.e. page 0 is the first page) - pub fn paginate(db: &mut Connection, page: i64, page_size: i64) -> QueryResult> { + pub fn paginate(db: &mut ConnectionType, page: i64, page_size: i64) -> QueryResult> { use crate::schema::todos::dsl::*; let page_size = if page_size < 1 { 1 } else { page_size }; @@ -78,13 +78,13 @@ impl Todo { }) } - pub fn update(db: &mut Connection, param_id: i32, item: &UpdateTodo) -> QueryResult { + pub fn update(db: &mut ConnectionType, param_id: i32, item: &UpdateTodo) -> QueryResult { use crate::schema::todos::dsl::*; diesel::update(todos.filter(id.eq(param_id))).set(item).get_result(db) } - pub fn delete(db: &mut Connection, param_id: i32) -> QueryResult { + pub fn delete(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::schema::todos::dsl::*; diesel::delete(todos.filter(id.eq(param_id))).execute(db) diff --git a/test/custom_model_and_schema_path/models/tableA/generated.rs b/test/custom_model_and_schema_path/models/tableA/generated.rs index fb2c61b8..79b1aa0d 100644 --- a/test/custom_model_and_schema_path/models/tableA/generated.rs +++ b/test/custom_model_and_schema_path/models/tableA/generated.rs @@ -6,7 +6,7 @@ use diesel::QueryResult; use serde::{Deserialize, Serialize}; -type Connection = diesel::r2d2::PooledConnection>; +type ConnectionType = diesel::r2d2::PooledConnection>; #[derive(Debug, Serialize, Deserialize, Clone, Queryable, Insertable, Selectable)] #[diesel(table_name=tableA, primary_key(_id))] @@ -34,20 +34,20 @@ pub struct PaginationResult { impl TableA { - pub fn create(db: &mut Connection, item: &CreateTableA) -> QueryResult { + pub fn create(db: &mut ConnectionType, item: &CreateTableA) -> QueryResult { use crate::data::schema::tableA::dsl::*; insert_into(tableA).values(item).get_result::(db) } - pub fn read(db: &mut Connection, param__id: i32) -> QueryResult { + pub fn read(db: &mut ConnectionType, param__id: i32) -> QueryResult { use crate::data::schema::tableA::dsl::*; tableA.filter(_id.eq(param__id)).first::(db) } /// Paginates through the table where page is a 0-based index (i.e. page 0 is the first page) - pub fn paginate(db: &mut Connection, page: i64, page_size: i64) -> QueryResult> { + pub fn paginate(db: &mut ConnectionType, page: i64, page_size: i64) -> QueryResult> { use crate::data::schema::tableA::dsl::*; let page_size = if page_size < 1 { 1 } else { page_size }; @@ -64,7 +64,7 @@ impl TableA { }) } - pub fn delete(db: &mut Connection, param__id: i32) -> QueryResult { + pub fn delete(db: &mut ConnectionType, param__id: i32) -> QueryResult { use crate::data::schema::tableA::dsl::*; diesel::delete(tableA.filter(_id.eq(param__id))).execute(db) diff --git a/test/custom_model_and_schema_path/models/tableB/generated.rs b/test/custom_model_and_schema_path/models/tableB/generated.rs index c23a7cb7..122d57e5 100644 --- a/test/custom_model_and_schema_path/models/tableB/generated.rs +++ b/test/custom_model_and_schema_path/models/tableB/generated.rs @@ -6,7 +6,7 @@ use diesel::QueryResult; use serde::{Deserialize, Serialize}; use crate::data::models::table_a::TableA; -type Connection = diesel::r2d2::PooledConnection>; +type ConnectionType = diesel::r2d2::PooledConnection>; #[derive(Debug, Serialize, Deserialize, Clone, Queryable, Insertable, AsChangeset, Identifiable, Associations, Selectable)] #[diesel(table_name=tableB, primary_key(_id), belongs_to(TableA, foreign_key=link))] @@ -41,20 +41,20 @@ pub struct PaginationResult { impl TableB { - pub fn create(db: &mut Connection, item: &CreateTableB) -> QueryResult { + pub fn create(db: &mut ConnectionType, item: &CreateTableB) -> QueryResult { use crate::data::schema::tableB::dsl::*; insert_into(tableB).values(item).get_result::(db) } - pub fn read(db: &mut Connection, param__id: i32) -> QueryResult { + pub fn read(db: &mut ConnectionType, param__id: i32) -> QueryResult { use crate::data::schema::tableB::dsl::*; tableB.filter(_id.eq(param__id)).first::(db) } /// Paginates through the table where page is a 0-based index (i.e. page 0 is the first page) - pub fn paginate(db: &mut Connection, page: i64, page_size: i64) -> QueryResult> { + pub fn paginate(db: &mut ConnectionType, page: i64, page_size: i64) -> QueryResult> { use crate::data::schema::tableB::dsl::*; let page_size = if page_size < 1 { 1 } else { page_size }; @@ -71,13 +71,13 @@ impl TableB { }) } - pub fn update(db: &mut Connection, param__id: i32, item: &UpdateTableB) -> QueryResult { + pub fn update(db: &mut ConnectionType, param__id: i32, item: &UpdateTableB) -> QueryResult { use crate::data::schema::tableB::dsl::*; diesel::update(tableB.filter(_id.eq(param__id))).set(item).get_result(db) } - pub fn delete(db: &mut Connection, param__id: i32) -> QueryResult { + pub fn delete(db: &mut ConnectionType, param__id: i32) -> QueryResult { use crate::data::schema::tableB::dsl::*; diesel::delete(tableB.filter(_id.eq(param__id))).execute(db) diff --git a/test/custom_model_path/models/tableA/generated.rs b/test/custom_model_path/models/tableA/generated.rs index ab2a9c0b..da3030f6 100644 --- a/test/custom_model_path/models/tableA/generated.rs +++ b/test/custom_model_path/models/tableA/generated.rs @@ -6,7 +6,7 @@ use diesel::QueryResult; use serde::{Deserialize, Serialize}; -type Connection = diesel::r2d2::PooledConnection>; +type ConnectionType = diesel::r2d2::PooledConnection>; #[derive(Debug, Serialize, Deserialize, Clone, Queryable, Insertable, Selectable)] #[diesel(table_name=tableA, primary_key(_id))] @@ -34,20 +34,20 @@ pub struct PaginationResult { impl TableA { - pub fn create(db: &mut Connection, item: &CreateTableA) -> QueryResult { + pub fn create(db: &mut ConnectionType, item: &CreateTableA) -> QueryResult { use crate::schema::tableA::dsl::*; insert_into(tableA).values(item).get_result::(db) } - pub fn read(db: &mut Connection, param__id: i32) -> QueryResult { + pub fn read(db: &mut ConnectionType, param__id: i32) -> QueryResult { use crate::schema::tableA::dsl::*; tableA.filter(_id.eq(param__id)).first::(db) } /// Paginates through the table where page is a 0-based index (i.e. page 0 is the first page) - pub fn paginate(db: &mut Connection, page: i64, page_size: i64) -> QueryResult> { + pub fn paginate(db: &mut ConnectionType, page: i64, page_size: i64) -> QueryResult> { use crate::schema::tableA::dsl::*; let page_size = if page_size < 1 { 1 } else { page_size }; @@ -64,7 +64,7 @@ impl TableA { }) } - pub fn delete(db: &mut Connection, param__id: i32) -> QueryResult { + pub fn delete(db: &mut ConnectionType, param__id: i32) -> QueryResult { use crate::schema::tableA::dsl::*; diesel::delete(tableA.filter(_id.eq(param__id))).execute(db) diff --git a/test/custom_model_path/models/tableB/generated.rs b/test/custom_model_path/models/tableB/generated.rs index 64a9c49e..194f4dda 100644 --- a/test/custom_model_path/models/tableB/generated.rs +++ b/test/custom_model_path/models/tableB/generated.rs @@ -6,7 +6,7 @@ use diesel::QueryResult; use serde::{Deserialize, Serialize}; use crate::data::models::table_a::TableA; -type Connection = diesel::r2d2::PooledConnection>; +type ConnectionType = diesel::r2d2::PooledConnection>; #[derive(Debug, Serialize, Deserialize, Clone, Queryable, Insertable, AsChangeset, Identifiable, Associations, Selectable)] #[diesel(table_name=tableB, primary_key(_id), belongs_to(TableA, foreign_key=link))] @@ -41,20 +41,20 @@ pub struct PaginationResult { impl TableB { - pub fn create(db: &mut Connection, item: &CreateTableB) -> QueryResult { + pub fn create(db: &mut ConnectionType, item: &CreateTableB) -> QueryResult { use crate::schema::tableB::dsl::*; insert_into(tableB).values(item).get_result::(db) } - pub fn read(db: &mut Connection, param__id: i32) -> QueryResult { + pub fn read(db: &mut ConnectionType, param__id: i32) -> QueryResult { use crate::schema::tableB::dsl::*; tableB.filter(_id.eq(param__id)).first::(db) } /// Paginates through the table where page is a 0-based index (i.e. page 0 is the first page) - pub fn paginate(db: &mut Connection, page: i64, page_size: i64) -> QueryResult> { + pub fn paginate(db: &mut ConnectionType, page: i64, page_size: i64) -> QueryResult> { use crate::schema::tableB::dsl::*; let page_size = if page_size < 1 { 1 } else { page_size }; @@ -71,13 +71,13 @@ impl TableB { }) } - pub fn update(db: &mut Connection, param__id: i32, item: &UpdateTableB) -> QueryResult { + pub fn update(db: &mut ConnectionType, param__id: i32, item: &UpdateTableB) -> QueryResult { use crate::schema::tableB::dsl::*; diesel::update(tableB.filter(_id.eq(param__id))).set(item).get_result(db) } - pub fn delete(db: &mut Connection, param__id: i32) -> QueryResult { + pub fn delete(db: &mut ConnectionType, param__id: i32) -> QueryResult { use crate::schema::tableB::dsl::*; diesel::delete(tableB.filter(_id.eq(param__id))).execute(db) diff --git a/test/manual_primary_keys/models/todos/generated.rs b/test/manual_primary_keys/models/todos/generated.rs index 85125c3a..a9eebc56 100644 --- a/test/manual_primary_keys/models/todos/generated.rs +++ b/test/manual_primary_keys/models/todos/generated.rs @@ -6,7 +6,7 @@ use diesel::QueryResult; use serde::{Deserialize, Serialize}; -type Connection = diesel::r2d2::PooledConnection>; +type ConnectionType = diesel::r2d2::PooledConnection>; #[derive(Debug, Serialize, Deserialize, Clone, Queryable, Insertable, Selectable)] #[diesel(table_name=todos, primary_key(id))] @@ -34,20 +34,20 @@ pub struct PaginationResult { impl Todo { - pub fn create(db: &mut Connection, item: &CreateTodo) -> QueryResult { + pub fn create(db: &mut ConnectionType, item: &CreateTodo) -> QueryResult { use crate::schema::todos::dsl::*; insert_into(todos).values(item).get_result::(db) } - pub fn read(db: &mut Connection, param_id: i32) -> QueryResult { + pub fn read(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::schema::todos::dsl::*; todos.filter(id.eq(param_id)).first::(db) } /// Paginates through the table where page is a 0-based index (i.e. page 0 is the first page) - pub fn paginate(db: &mut Connection, page: i64, page_size: i64) -> QueryResult> { + pub fn paginate(db: &mut ConnectionType, page: i64, page_size: i64) -> QueryResult> { use crate::schema::todos::dsl::*; let page_size = if page_size < 1 { 1 } else { page_size }; @@ -64,7 +64,7 @@ impl Todo { }) } - pub fn delete(db: &mut Connection, param_id: i32) -> QueryResult { + pub fn delete(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::schema::todos::dsl::*; diesel::delete(todos.filter(id.eq(param_id))).execute(db) diff --git a/test/multiple_primary_keys/models/users/generated.rs b/test/multiple_primary_keys/models/users/generated.rs index 2f3983cd..bb39ae0b 100644 --- a/test/multiple_primary_keys/models/users/generated.rs +++ b/test/multiple_primary_keys/models/users/generated.rs @@ -6,7 +6,7 @@ use diesel::QueryResult; use serde::{Deserialize, Serialize}; -type Connection = diesel::r2d2::PooledConnection>; +type ConnectionType = diesel::r2d2::PooledConnection>; #[derive(Debug, Serialize, Deserialize, Clone, Queryable, Insertable, AsChangeset, Selectable)] #[diesel(table_name=users, primary_key(name,address))] @@ -43,20 +43,20 @@ pub struct PaginationResult { impl User { - pub fn create(db: &mut Connection, item: &CreateUser) -> QueryResult { + pub fn create(db: &mut ConnectionType, item: &CreateUser) -> QueryResult { use crate::schema::users::dsl::*; insert_into(users).values(item).get_result::(db) } - pub fn read(db: &mut Connection, param_name: String, param_address: String) -> QueryResult { + pub fn read(db: &mut ConnectionType, param_name: String, param_address: String) -> QueryResult { use crate::schema::users::dsl::*; users.filter(name.eq(param_name)).filter(address.eq(param_address)).first::(db) } /// Paginates through the table where page is a 0-based index (i.e. page 0 is the first page) - pub fn paginate(db: &mut Connection, page: i64, page_size: i64) -> QueryResult> { + pub fn paginate(db: &mut ConnectionType, page: i64, page_size: i64) -> QueryResult> { use crate::schema::users::dsl::*; let page_size = if page_size < 1 { 1 } else { page_size }; @@ -73,13 +73,13 @@ impl User { }) } - pub fn update(db: &mut Connection, param_name: String, param_address: String, item: &UpdateUser) -> QueryResult { + pub fn update(db: &mut ConnectionType, param_name: String, param_address: String, item: &UpdateUser) -> QueryResult { use crate::schema::users::dsl::*; diesel::update(users.filter(name.eq(param_name)).filter(address.eq(param_address))).set(item).get_result(db) } - pub fn delete(db: &mut Connection, param_name: String, param_address: String) -> QueryResult { + pub fn delete(db: &mut ConnectionType, param_name: String, param_address: String) -> QueryResult { use crate::schema::users::dsl::*; diesel::delete(users.filter(name.eq(param_name)).filter(address.eq(param_address))).execute(db) diff --git a/test/simple_table/models/todos/generated.rs b/test/simple_table/models/todos/generated.rs index 8ca52632..65c94a10 100644 --- a/test/simple_table/models/todos/generated.rs +++ b/test/simple_table/models/todos/generated.rs @@ -6,7 +6,7 @@ use diesel::QueryResult; use serde::{Deserialize, Serialize}; -type Connection = diesel::r2d2::PooledConnection>; +type ConnectionType = diesel::r2d2::PooledConnection>; #[derive(Debug, Serialize, Deserialize, Clone, Queryable, Insertable, AsChangeset, Selectable)] #[diesel(table_name=todos, primary_key(id))] @@ -56,20 +56,20 @@ pub struct PaginationResult { impl Todo { - pub fn create(db: &mut Connection, item: &CreateTodo) -> QueryResult { + pub fn create(db: &mut ConnectionType, item: &CreateTodo) -> QueryResult { use crate::schema::todos::dsl::*; insert_into(todos).values(item).get_result::(db) } - pub fn read(db: &mut Connection, param_id: i32) -> QueryResult { + pub fn read(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::schema::todos::dsl::*; todos.filter(id.eq(param_id)).first::(db) } /// Paginates through the table where page is a 0-based index (i.e. page 0 is the first page) - pub fn paginate(db: &mut Connection, page: i64, page_size: i64) -> QueryResult> { + pub fn paginate(db: &mut ConnectionType, page: i64, page_size: i64) -> QueryResult> { use crate::schema::todos::dsl::*; let page_size = if page_size < 1 { 1 } else { page_size }; @@ -86,13 +86,13 @@ impl Todo { }) } - pub fn update(db: &mut Connection, param_id: i32, item: &UpdateTodo) -> QueryResult { + pub fn update(db: &mut ConnectionType, param_id: i32, item: &UpdateTodo) -> QueryResult { use crate::schema::todos::dsl::*; diesel::update(todos.filter(id.eq(param_id))).set(item).get_result(db) } - pub fn delete(db: &mut Connection, param_id: i32) -> QueryResult { + pub fn delete(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::schema::todos::dsl::*; diesel::delete(todos.filter(id.eq(param_id))).execute(db) diff --git a/test/simple_table_async/models/todos/generated.rs b/test/simple_table_async/models/todos/generated.rs index 0f3bbea2..2fab030b 100644 --- a/test/simple_table_async/models/todos/generated.rs +++ b/test/simple_table_async/models/todos/generated.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; use diesel_async::RunQueryDsl; -type Connection = diesel_async::pooled_connection::deadpool::Object; +type ConnectionType = diesel_async::pooled_connection::deadpool::Object; #[derive(Debug, Serialize, Deserialize, Clone, Queryable, Insertable, AsChangeset, Selectable)] #[diesel(table_name=todos, primary_key(id))] @@ -51,20 +51,20 @@ pub struct PaginationResult { impl Todo { - pub async fn create(db: &mut Connection, item: &CreateTodo) -> QueryResult { + pub async fn create(db: &mut ConnectionType, item: &CreateTodo) -> QueryResult { use crate::schema::todos::dsl::*; insert_into(todos).values(item).get_result::(db).await } - pub async fn read(db: &mut Connection, param_id: i32) -> QueryResult { + pub async fn read(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::schema::todos::dsl::*; todos.filter(id.eq(param_id)).first::(db).await } /// Paginates through the table where page is a 0-based index (i.e. page 0 is the first page) - pub async fn paginate(db: &mut Connection, page: i64, page_size: i64) -> QueryResult> { + pub async fn paginate(db: &mut ConnectionType, page: i64, page_size: i64) -> QueryResult> { use crate::schema::todos::dsl::*; let page_size = if page_size < 1 { 1 } else { page_size }; @@ -81,13 +81,13 @@ impl Todo { }) } - pub async fn update(db: &mut Connection, param_id: i32, item: &UpdateTodo) -> QueryResult { + pub async fn update(db: &mut ConnectionType, param_id: i32, item: &UpdateTodo) -> QueryResult { use crate::schema::todos::dsl::*; diesel::update(todos.filter(id.eq(param_id))).set(item).get_result(db).await } - pub async fn delete(db: &mut Connection, param_id: i32) -> QueryResult { + pub async fn delete(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::schema::todos::dsl::*; diesel::delete(todos.filter(id.eq(param_id))).execute(db).await diff --git a/test/simple_table_custom_schema_path/models/todos/generated.rs b/test/simple_table_custom_schema_path/models/todos/generated.rs index 031cfee0..586e8fe2 100644 --- a/test/simple_table_custom_schema_path/models/todos/generated.rs +++ b/test/simple_table_custom_schema_path/models/todos/generated.rs @@ -6,7 +6,7 @@ use diesel::QueryResult; use serde::{Deserialize, Serialize}; -type Connection = diesel::r2d2::PooledConnection>; +type ConnectionType = diesel::r2d2::PooledConnection>; #[derive(Debug, Serialize, Deserialize, Clone, Queryable, Insertable, AsChangeset, Selectable)] #[diesel(table_name=todos, primary_key(id))] @@ -50,20 +50,20 @@ pub struct PaginationResult { impl Todo { - pub fn create(db: &mut Connection, item: &CreateTodo) -> QueryResult { + pub fn create(db: &mut ConnectionType, item: &CreateTodo) -> QueryResult { use crate::data::schema::todos::dsl::*; insert_into(todos).values(item).get_result::(db) } - pub fn read(db: &mut Connection, param_id: i32) -> QueryResult { + pub fn read(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::data::schema::todos::dsl::*; todos.filter(id.eq(param_id)).first::(db) } /// Paginates through the table where page is a 0-based index (i.e. page 0 is the first page) - pub fn paginate(db: &mut Connection, page: i64, page_size: i64) -> QueryResult> { + pub fn paginate(db: &mut ConnectionType, page: i64, page_size: i64) -> QueryResult> { use crate::data::schema::todos::dsl::*; let page_size = if page_size < 1 { 1 } else { page_size }; @@ -80,13 +80,13 @@ impl Todo { }) } - pub fn update(db: &mut Connection, param_id: i32, item: &UpdateTodo) -> QueryResult { + pub fn update(db: &mut ConnectionType, param_id: i32, item: &UpdateTodo) -> QueryResult { use crate::data::schema::todos::dsl::*; diesel::update(todos.filter(id.eq(param_id))).set(item).get_result(db) } - pub fn delete(db: &mut Connection, param_id: i32) -> QueryResult { + pub fn delete(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::data::schema::todos::dsl::*; diesel::delete(todos.filter(id.eq(param_id))).execute(db) diff --git a/test/simple_table_no_serde/models/todos/generated.rs b/test/simple_table_no_serde/models/todos/generated.rs index 049cfcfe..7c2b3e10 100644 --- a/test/simple_table_no_serde/models/todos/generated.rs +++ b/test/simple_table_no_serde/models/todos/generated.rs @@ -6,7 +6,7 @@ use diesel::QueryResult; -type Connection = diesel::r2d2::PooledConnection>; +type ConnectionType = diesel::r2d2::PooledConnection>; #[derive(Debug, Clone, Queryable, Insertable, AsChangeset, Selectable)] #[diesel(table_name=todos, primary_key(id))] @@ -50,20 +50,20 @@ pub struct PaginationResult { impl Todo { - pub fn create(db: &mut Connection, item: &CreateTodo) -> QueryResult { + pub fn create(db: &mut ConnectionType, item: &CreateTodo) -> QueryResult { use crate::schema::todos::dsl::*; insert_into(todos).values(item).get_result::(db) } - pub fn read(db: &mut Connection, param_id: i32) -> QueryResult { + pub fn read(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::schema::todos::dsl::*; todos.filter(id.eq(param_id)).first::(db) } /// Paginates through the table where page is a 0-based index (i.e. page 0 is the first page) - pub fn paginate(db: &mut Connection, page: i64, page_size: i64) -> QueryResult> { + pub fn paginate(db: &mut ConnectionType, page: i64, page_size: i64) -> QueryResult> { use crate::schema::todos::dsl::*; let page_size = if page_size < 1 { 1 } else { page_size }; @@ -80,13 +80,13 @@ impl Todo { }) } - pub fn update(db: &mut Connection, param_id: i32, item: &UpdateTodo) -> QueryResult { + pub fn update(db: &mut ConnectionType, param_id: i32, item: &UpdateTodo) -> QueryResult { use crate::schema::todos::dsl::*; diesel::update(todos.filter(id.eq(param_id))).set(item).get_result(db) } - pub fn delete(db: &mut Connection, param_id: i32) -> QueryResult { + pub fn delete(db: &mut ConnectionType, param_id: i32) -> QueryResult { use crate::schema::todos::dsl::*; diesel::delete(todos.filter(id.eq(param_id))).execute(db) diff --git a/test/use_statements/models/fang_tasks/generated.rs b/test/use_statements/models/fang_tasks/generated.rs index 151f85a7..0a570359 100644 --- a/test/use_statements/models/fang_tasks/generated.rs +++ b/test/use_statements/models/fang_tasks/generated.rs @@ -6,7 +6,7 @@ use diesel::QueryResult; use serde::{Deserialize, Serialize}; -type Connection = diesel::r2d2::PooledConnection>; +type ConnectionType = diesel::r2d2::PooledConnection>; #[derive(Debug, Serialize, Deserialize, Clone, Queryable, Insertable, AsChangeset, Selectable)] #[diesel(table_name=fang_tasks, primary_key(id))] @@ -65,20 +65,20 @@ pub struct PaginationResult { impl FangTask { - pub fn create(db: &mut Connection, item: &CreateFangTask) -> QueryResult { + pub fn create(db: &mut ConnectionType, item: &CreateFangTask) -> QueryResult { use crate::schema::fang_tasks::dsl::*; insert_into(fang_tasks).values(item).get_result::(db) } - pub fn read(db: &mut Connection, param_id: uuid::Uuid) -> QueryResult { + pub fn read(db: &mut ConnectionType, param_id: uuid::Uuid) -> QueryResult { use crate::schema::fang_tasks::dsl::*; fang_tasks.filter(id.eq(param_id)).first::(db) } /// Paginates through the table where page is a 0-based index (i.e. page 0 is the first page) - pub fn paginate(db: &mut Connection, page: i64, page_size: i64) -> QueryResult> { + pub fn paginate(db: &mut ConnectionType, page: i64, page_size: i64) -> QueryResult> { use crate::schema::fang_tasks::dsl::*; let page_size = if page_size < 1 { 1 } else { page_size }; @@ -95,13 +95,13 @@ impl FangTask { }) } - pub fn update(db: &mut Connection, param_id: uuid::Uuid, item: &UpdateFangTask) -> QueryResult { + pub fn update(db: &mut ConnectionType, param_id: uuid::Uuid, item: &UpdateFangTask) -> QueryResult { use crate::schema::fang_tasks::dsl::*; diesel::update(fang_tasks.filter(id.eq(param_id))).set(item).get_result(db) } - pub fn delete(db: &mut Connection, param_id: uuid::Uuid) -> QueryResult { + pub fn delete(db: &mut ConnectionType, param_id: uuid::Uuid) -> QueryResult { use crate::schema::fang_tasks::dsl::*; diesel::delete(fang_tasks.filter(id.eq(param_id))).execute(db)