fix sql errors
This commit is contained in:
parent
593a0f0ac0
commit
3a469d5d7c
2 changed files with 5 additions and 10 deletions
|
|
@ -11,7 +11,7 @@ pub async fn create_chat(db: &DbPool, chat: &types::Chat) -> Result<Chat, sqlx::
|
|||
.bind(chat.id.0 as i64)
|
||||
.bind(chat.title())
|
||||
.bind(chat.username())
|
||||
.bind(0)
|
||||
.bind(false)
|
||||
.execute(db)
|
||||
.await?;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,12 +3,7 @@ use teloxide::types;
|
|||
use super::{DbPool, User};
|
||||
use crate::unwrap_or_create;
|
||||
|
||||
pub async fn create_user(
|
||||
db: &DbPool,
|
||||
user: &types::User,
|
||||
can_download: bool,
|
||||
is_admin: bool,
|
||||
) -> Result<User, sqlx::Error> {
|
||||
pub async fn create_user(db: &DbPool, user: &types::User) -> Result<User, sqlx::Error> {
|
||||
sqlx::query(
|
||||
r#"INSERT OR IGNORE INTO "user"
|
||||
(tg_id, username, first_name, last_name, can_download, is_admin, has_private_chat)
|
||||
|
|
@ -18,8 +13,8 @@ pub async fn create_user(
|
|||
.bind(&user.username)
|
||||
.bind(&user.first_name)
|
||||
.bind(&user.last_name)
|
||||
.bind(can_download as i64)
|
||||
.bind(is_admin as i64)
|
||||
.bind(false)
|
||||
.bind(false)
|
||||
.bind(0)
|
||||
.execute(db)
|
||||
.await?;
|
||||
|
|
@ -38,5 +33,5 @@ pub async fn find_or_create_user(db: &DbPool, user: &types::User) -> Result<User
|
|||
.fetch_one(db)
|
||||
.await;
|
||||
|
||||
unwrap_or_create!(db, user, res, create_user, false, false)
|
||||
unwrap_or_create!(db, user, res, create_user)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue