remote postgres dep and fix save_user function

This commit is contained in:
jake 2020-10-25 20:19:05 -06:00
parent 0db9a73849
commit 19e30f34e6
3 changed files with 2 additions and 9 deletions

View File

@ -30,7 +30,6 @@ ages-prs = "0.1"
async-trait = "0.1.31" async-trait = "0.1.31"
lazy_static = "1.4.0" lazy_static = "1.4.0"
barrel = { version = "0.6.5", features = ["pg"] } barrel = { version = "0.6.5", features = ["pg"] }
postgres = "0.17.5"
refinery = { version = "0.3.0", features = ["postgres"] } refinery = { version = "0.3.0", features = ["postgres"] }
sqlx = { version = "0.4.0-beta.1", features = ["postgres", "json", "chrono"] } sqlx = { version = "0.4.0-beta.1", features = ["postgres", "json", "chrono"] }

View File

@ -13,9 +13,6 @@ use crate::ship::map::MapArea;
use sqlx::postgres::PgPoolOptions; use sqlx::postgres::PgPoolOptions;
use sqlx::Row; use sqlx::Row;
use sqlx::Execute; use sqlx::Execute;
use postgres::{Client, NoTls};
#[derive(Debug, sqlx::FromRow)] #[derive(Debug, sqlx::FromRow)]
pub struct PgUserAccount { pub struct PgUserAccount {
id: i32, id: i32,

View File

@ -14,9 +14,6 @@ use crate::entity::item::*;
use super::models::*; use super::models::*;
use sqlx::postgres::PgPoolOptions; use sqlx::postgres::PgPoolOptions;
use sqlx::Row;
use sqlx::Execute;
use postgres::{Client, NoTls};
mod embedded { mod embedded {
use refinery::embed_migrations; use refinery::embed_migrations;
@ -123,14 +120,14 @@ impl EntityGateway for PostgresGateway {
} }
async fn save_user(&mut self, user: &UserAccountEntity) -> Result<(), GatewayError> { 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.username)
.bind(&user.password) .bind(&user.password)
.bind(&user.banned_until) .bind(&user.banned_until)
.bind(&user.muted_until) .bind(&user.muted_until)
.bind(&user.flags) .bind(&user.flags)
.bind(&user.id.0) .bind(&user.id.0)
.fetch_one(&self.pool).await?; .execute(&self.pool).await?;
Ok(()) Ok(())
} }