diff --git a/src/modules/user/user_providers.rs b/src/modules/user/user_providers.rs index 729f2de..abd4235 100644 --- a/src/modules/user/user_providers.rs +++ b/src/modules/user/user_providers.rs @@ -3,12 +3,12 @@ use crate::utils::{ }; use actix_web::{web::Data, HttpResponse}; use deadpool_postgres::Pool; -use sql_builder::SqlBuilder; +use sql_builder::{quote, SqlBuilder}; pub async fn email_exists(pg_pool: Data, email: String) -> Result<(), HttpResponse> { let mut sql_builder = SqlBuilder::select_from("users"); sql_builder.field("id"); - sql_builder.or_where_eq("email", email.clone()); + sql_builder.or_where_eq("email", "e(email.clone())); let rows = match query_constructor_executor(pg_pool, sql_builder).await { Ok(x) => x, @@ -31,7 +31,7 @@ pub async fn email_exists(pg_pool: Data, email: String) -> Result<(), Http pub async fn email_not_exists(pg_pool: Data, email: String) -> Result<(), HttpResponse> { let mut sql_builder = SqlBuilder::select_from("users"); sql_builder.field("id"); - sql_builder.or_where_eq("email", email.clone()); + sql_builder.or_where_eq("email", "e(email.clone())); let rows = match query_constructor_executor(pg_pool, sql_builder).await { Ok(x) => x, diff --git a/src/modules/user/user_queues.rs b/src/modules/user/user_queues.rs index fb262f3..16d75ea 100644 --- a/src/modules/user/user_queues.rs +++ b/src/modules/user/user_queues.rs @@ -110,7 +110,7 @@ async fn put_user_queue(pool: Pool, queue: Arc) -> Result<(), H sql_builder.set("password", "e(user.new_password.clone())); sql_builder.set("email", "e(user.new_email.clone())); sql_builder.set("updated_at", "e(updated_at)); - sql_builder.or_where_eq("id", user_id); + sql_builder.or_where_eq("id", "e(user_id)); let mut this_sql = match sql_builder.sql() { Ok(x) => x, @@ -171,7 +171,7 @@ async fn delete_user_queue(pool: Pool, queue: Arc) -> Result let user_id = queue.pop().await; let mut sql_builder = SqlBuilder::delete_from("salt"); - sql_builder.or_where_eq("user_id", user_id.clone()); + sql_builder.or_where_eq("user_id", "e(user_id.clone())); let mut this_sql = match sql_builder.sql() { Ok(x) => x, @@ -181,7 +181,7 @@ async fn delete_user_queue(pool: Pool, queue: Arc) -> Result salt_sql.push_str(&this_sql); let mut sql_builder = SqlBuilder::delete_from("users"); - sql_builder.or_where_eq("id", user_id); + sql_builder.or_where_eq("id", "e(user_id)); let mut this_sql = match sql_builder.sql() { Ok(x) => x, diff --git a/src/modules/user/user_repositories.rs b/src/modules/user/user_repositories.rs index e400747..006b431 100644 --- a/src/modules/user/user_repositories.rs +++ b/src/modules/user/user_repositories.rs @@ -12,6 +12,7 @@ use actix_web::{ web::{Data, Json, Query}, HttpResponse, }; +use sql_builder::quote; use std::sync::Arc; fn user_dto_constructor(rows: Vec) -> UserDTO { @@ -35,7 +36,7 @@ pub async fn get_user_salt_repository( ) -> Result { let mut sql_builder = sql_builder::SqlBuilder::select_from("salt"); sql_builder.field("salt"); - sql_builder.or_where_eq("user_id", user_id); + sql_builder.or_where_eq("user_id", "e(user_id)); let rows = match query_constructor_executor(pg_pool, sql_builder).await { Ok(x) => x, @@ -85,7 +86,7 @@ pub async fn login_user_repository( pg_pool: Data, ) -> Result { let mut sql_builder = sql_builder::SqlBuilder::select_from("users"); - sql_builder.or_where_eq("email", email.clone()); + sql_builder.or_where_eq("email", "e(email.clone())); let rows = match query_constructor_executor(pg_pool, sql_builder).await { Ok(x) => x, @@ -111,7 +112,7 @@ pub async fn detail_user_repository( user_id: String, ) -> Result { let mut sql_builder = sql_builder::SqlBuilder::select_from("users"); - sql_builder.or_where_eq("id", user_id); + sql_builder.or_where_eq("id", "e(user_id)); let rows = match query_constructor_executor(pg_pool, sql_builder).await { Ok(x) => x,