Skip to content

Commit

Permalink
add allow(dead_code)
Browse files Browse the repository at this point in the history
  • Loading branch information
friendbear committed Jun 19, 2024
1 parent e928b80 commit 84a562e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions practice_collection/or_mapper/src/product_repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use crate::modules::product::{Column, Entity as Product, Model};
use crate::repository::Repository;
use anyhow::{Error, Result};
use async_trait::async_trait;
use sea_orm::{ActiveModelTrait, Statement, ConnectionTrait};
use sea_orm::ActiveValue::Set; // {NotSet, Set, Unchanged};
use sea_orm::ColumnTrait;
use sea_orm::DatabaseTransaction;
use sea_orm::EntityTrait;
use sea_orm::IntoActiveModel;
use sea_orm::QueryFilter;
use sea_orm::QueryOrder;
use sea_orm::{ActiveModelTrait, ConnectionTrait, Statement};

pub struct ProductRepository;
impl ProductRepository {
Expand Down Expand Up @@ -94,11 +94,11 @@ impl ProductRepository {
Ok(product_and_category)
}
#[allow(dead_code)]
async fn select_by_id_stmt(&self, db: &DatabaseTransaction, id:i32) -> Result<Model> {
async fn select_by_id_stmt(&self, db: &DatabaseTransaction, id: i32) -> Result<Model> {
let stmt = Statement::from_sql_and_values(
sea_orm::DatabaseBackend::Postgres,
r#"SELECT id, name, price, category_id FROM product WHERE id = $1"#,
vec![id.into()]
vec![id.into()],
);
let row = Product::find().from_raw_sql(stmt).one(db).await?;
row.ok_or(Error::msg("Not found."))
Expand All @@ -108,7 +108,7 @@ impl ProductRepository {
let stmt = Statement::from_sql_and_values(
sea_orm::DatabaseBackend::Postgres,
r#"INSERT INTO product(name, category_id) VALUES($1, $2)"#,
vec![row.name.into(), row.category_id.into()]
vec![row.name.into(), row.category_id.into()],
);
let result = db.execute(stmt).await?;
Ok(result.rows_affected())
Expand Down
1 change: 1 addition & 0 deletions practice_collection/or_mapper/src/repository.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(dead_code)]
use anyhow::Result;
use async_trait::async_trait;

Expand Down

0 comments on commit 84a562e

Please sign in to comment.