From 19e30f34e6b51910268b0541b4dcace6132e54be Mon Sep 17 00:00:00 2001 From: jake Date: Sun, 25 Oct 2020 20:19:05 -0600 Subject: [PATCH] remote postgres dep and fix save_user function --- Cargo.toml | 1 - src/entity/gateway/postgres/models.rs | 3 --- src/entity/gateway/postgres/postgres.rs | 7 ++----- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4720390..52c528e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,6 @@ ages-prs = "0.1" async-trait = "0.1.31" lazy_static = "1.4.0" barrel = { version = "0.6.5", features = ["pg"] } -postgres = "0.17.5" refinery = { version = "0.3.0", features = ["postgres"] } sqlx = { version = "0.4.0-beta.1", features = ["postgres", "json", "chrono"] } diff --git a/src/entity/gateway/postgres/models.rs b/src/entity/gateway/postgres/models.rs index a987ba2..f60a9cf 100644 --- a/src/entity/gateway/postgres/models.rs +++ b/src/entity/gateway/postgres/models.rs @@ -13,9 +13,6 @@ use crate::ship::map::MapArea; use sqlx::postgres::PgPoolOptions; use sqlx::Row; use sqlx::Execute; -use postgres::{Client, NoTls}; - - #[derive(Debug, sqlx::FromRow)] pub struct PgUserAccount { id: i32, diff --git a/src/entity/gateway/postgres/postgres.rs b/src/entity/gateway/postgres/postgres.rs index a9f2f2a..17877df 100644 --- a/src/entity/gateway/postgres/postgres.rs +++ b/src/entity/gateway/postgres/postgres.rs @@ -14,9 +14,6 @@ use crate::entity::item::*; use super::models::*; use sqlx::postgres::PgPoolOptions; -use sqlx::Row; -use sqlx::Execute; -use postgres::{Client, NoTls}; mod embedded { use refinery::embed_migrations; @@ -123,14 +120,14 @@ impl EntityGateway for PostgresGateway { } async fn save_user(&mut self, user: &UserAccountEntity) -> Result<(), GatewayError> { - sqlx::query("UPDATE user_accounts set name=$1, password=$2, banned=$3, muted=$4, flags=$5 where id=$6") + sqlx::query("UPDATE user_accounts set username=$1, password=$2, banned=$3, muted=$4, flags=$5 where id=$6") .bind(&user.username) .bind(&user.password) .bind(&user.banned_until) .bind(&user.muted_until) .bind(&user.flags) .bind(&user.id.0) - .fetch_one(&self.pool).await?; + .execute(&self.pool).await?; Ok(()) }