Use date_trunc instead of splitting date into year and month

This commit is contained in:
2021-12-08 15:15:35 +00:00
parent c3a022b595
commit 7cb7527704
5 changed files with 36 additions and 45 deletions

View File

@ -64,7 +64,7 @@ func (q *Queries) DeleteAllTransactions(ctx context.Context, budgetID uuid.UUID)
}
const getTransactionsByMonthAndCategory = `-- name: GetTransactionsByMonthAndCategory :many
SELECT year, month, category_id, budget_id, amount
SELECT date, category_id, budget_id, amount
FROM transactions_by_month
WHERE transactions_by_month.budget_id = $1
`
@ -79,8 +79,7 @@ func (q *Queries) GetTransactionsByMonthAndCategory(ctx context.Context, budgetI
for rows.Next() {
var i TransactionsByMonth
if err := rows.Scan(
&i.Year,
&i.Month,
&i.Date,
&i.CategoryID,
&i.BudgetID,
&i.Amount,