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

@ -54,7 +54,7 @@ func (q *Queries) DeleteAllAssignments(ctx context.Context, budgetID uuid.UUID)
}
const getAssignmentsByMonthAndCategory = `-- name: GetAssignmentsByMonthAndCategory :many
SELECT year, month, category_id, budget_id, amount
SELECT date, category_id, budget_id, amount
FROM assignments_by_month
WHERE assignments_by_month.budget_id = $1
`
@ -69,8 +69,7 @@ func (q *Queries) GetAssignmentsByMonthAndCategory(ctx context.Context, budgetID
for rows.Next() {
var i AssignmentsByMonth
if err := rows.Scan(
&i.Year,
&i.Month,
&i.Date,
&i.CategoryID,
&i.BudgetID,
&i.Amount,