diff --git a/postgres/budgets.sql.go b/postgres/budgets.sql.go index e4827e1..328941d 100644 --- a/postgres/budgets.sql.go +++ b/postgres/budgets.sql.go @@ -17,7 +17,7 @@ RETURNING id, name, last_modification ` func (q *Queries) CreateBudget(ctx context.Context, name string) (Budget, error) { - row := q.db.QueryRowContext(ctx, createBudget, name) + row := q.db.QueryRow(ctx, createBudget, name) var i Budget err := row.Scan(&i.ID, &i.Name, &i.LastModification) return i, err @@ -29,7 +29,7 @@ WHERE id = $1 ` func (q *Queries) GetBudget(ctx context.Context, id uuid.UUID) (Budget, error) { - row := q.db.QueryRowContext(ctx, getBudget, id) + row := q.db.QueryRow(ctx, getBudget, id) var i Budget err := row.Scan(&i.ID, &i.Name, &i.LastModification) return i, err @@ -42,7 +42,7 @@ WHERE user_budgets.user_id = $1 ` func (q *Queries) GetBudgetsForUser(ctx context.Context, userID uuid.UUID) ([]Budget, error) { - rows, err := q.db.QueryContext(ctx, getBudgetsForUser, userID) + rows, err := q.db.Query(ctx, getBudgetsForUser, userID) if err != nil { return nil, err } @@ -55,9 +55,6 @@ func (q *Queries) GetBudgetsForUser(ctx context.Context, userID uuid.UUID) ([]Bu } items = append(items, i) } - if err := rows.Close(); err != nil { - return nil, err - } if err := rows.Err(); err != nil { return nil, err } diff --git a/postgres/transactions.sql.go b/postgres/transactions.sql.go index 6963995..18d39fa 100644 --- a/postgres/transactions.sql.go +++ b/postgres/transactions.sql.go @@ -5,10 +5,10 @@ package postgres import ( "context" - "database/sql" "time" "github.com/google/uuid" + "github.com/jackc/pgtype" ) const createTransaction = `-- name: CreateTransaction :one @@ -20,14 +20,14 @@ RETURNING id, date, memo, amount, account_id, payee_id type CreateTransactionParams struct { Date time.Time - Memo sql.NullString - Amount string + Memo string + Amount pgtype.Numeric AccountID uuid.UUID PayeeID uuid.NullUUID } func (q *Queries) CreateTransaction(ctx context.Context, arg CreateTransactionParams) (Transaction, error) { - row := q.db.QueryRowContext(ctx, createTransaction, + row := q.db.QueryRow(ctx, createTransaction, arg.Date, arg.Memo, arg.Amount, @@ -52,7 +52,7 @@ WHERE transactions.account_id = $1 ` func (q *Queries) GetTransactionsForAccount(ctx context.Context, accountID uuid.UUID) ([]Transaction, error) { - rows, err := q.db.QueryContext(ctx, getTransactionsForAccount, accountID) + rows, err := q.db.Query(ctx, getTransactionsForAccount, accountID) if err != nil { return nil, err } @@ -72,9 +72,6 @@ func (q *Queries) GetTransactionsForAccount(ctx context.Context, accountID uuid. } items = append(items, i) } - if err := rows.Close(); err != nil { - return nil, err - } if err := rows.Err(); err != nil { return nil, err } @@ -88,7 +85,7 @@ WHERE accounts.budget_id = $1 ` func (q *Queries) GetTransactionsForBudget(ctx context.Context, budgetID uuid.UUID) ([]Transaction, error) { - rows, err := q.db.QueryContext(ctx, getTransactionsForBudget, budgetID) + rows, err := q.db.Query(ctx, getTransactionsForBudget, budgetID) if err != nil { return nil, err } @@ -108,9 +105,6 @@ func (q *Queries) GetTransactionsForBudget(ctx context.Context, budgetID uuid.UU } items = append(items, i) } - if err := rows.Close(); err != nil { - return nil, err - } if err := rows.Err(); err != nil { return nil, err } diff --git a/postgres/user_budgets.sql.go b/postgres/user_budgets.sql.go index 4740c0e..c1e07ba 100644 --- a/postgres/user_budgets.sql.go +++ b/postgres/user_budgets.sql.go @@ -22,7 +22,7 @@ type LinkBudgetToUserParams struct { } func (q *Queries) LinkBudgetToUser(ctx context.Context, arg LinkBudgetToUserParams) (UserBudget, error) { - row := q.db.QueryRowContext(ctx, linkBudgetToUser, arg.UserID, arg.BudgetID) + row := q.db.QueryRow(ctx, linkBudgetToUser, arg.UserID, arg.BudgetID) var i UserBudget err := row.Scan(&i.UserID, &i.BudgetID) return i, err diff --git a/postgres/users.sql.go b/postgres/users.sql.go index cdf53b8..b4bb118 100644 --- a/postgres/users.sql.go +++ b/postgres/users.sql.go @@ -24,7 +24,7 @@ type CreateUserParams struct { } func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) { - row := q.db.QueryRowContext(ctx, createUser, + row := q.db.QueryRow(ctx, createUser, arg.ID, arg.Email, arg.Name, @@ -46,7 +46,7 @@ WHERE id = $1 ` func (q *Queries) GetUser(ctx context.Context, id uuid.UUID) (User, error) { - row := q.db.QueryRowContext(ctx, getUser, id) + row := q.db.QueryRow(ctx, getUser, id) var i User err := row.Scan( &i.ID, @@ -63,7 +63,7 @@ WHERE email = $1 ` func (q *Queries) GetUserByUsername(ctx context.Context, email string) (User, error) { - row := q.db.QueryRowContext(ctx, getUserByUsername, email) + row := q.db.QueryRow(ctx, getUserByUsername, email) var i User err := row.Scan( &i.ID,