diff options
author | Joris | 2023-04-17 20:56:53 +0200 |
---|---|---|
committer | Joris | 2023-04-17 20:56:53 +0200 |
commit | 3932daa26360d6e03807381d0b8ffa2d0e704847 (patch) | |
tree | 099f92c176ba783bccc5c307927e1effe7c2cd9c /src/db | |
parent | 8dcb9c6fff82f9e353e0f92b417dd803199f4257 (diff) |
Validate income date from body
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/incomes.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/db/incomes.rs b/src/db/incomes.rs index f2eaf1c..2952d62 100644 --- a/src/db/incomes.rs +++ b/src/db/incomes.rs @@ -139,7 +139,7 @@ VALUES "#, ) .bind(i.user_id) - .bind(NaiveDate::from_ymd_opt(i.year, i.month, 1)?) + .bind(i.date) .bind(i.amount) .execute(pool) .await; @@ -156,8 +156,7 @@ VALUES pub async fn defined_at( pool: &SqlitePool, user_id: i64, - month: u32, - year: i32, + date: NaiveDate, ) -> Vec<i64> { let query = r#" SELECT @@ -172,7 +171,7 @@ WHERE let res = sqlx::query(&query) .bind(user_id) - .bind(NaiveDate::from_ymd(year, month, 1)) + .bind(date) .map(|row: SqliteRow| row.get("id")) .fetch_all(pool) .await; @@ -202,7 +201,7 @@ WHERE "#, ) .bind(i.user_id) - .bind(NaiveDate::from_ymd(i.year, i.month, 1)) + .bind(i.date) .bind(i.amount) .bind(id) .execute(pool) |