diff options
Diffstat (limited to 'model/users.sql.go')
-rw-r--r-- | model/users.sql.go | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/model/users.sql.go b/model/users.sql.go index 87ae961..e63dacc 100644 --- a/model/users.sql.go +++ b/model/users.sql.go @@ -12,16 +12,16 @@ import ( const getUserById = `-- name: GetUserById :one SELECT id, name, pwd, description FROM users - WHERE id = ? + WHERE id = $1 ` // GetUserById // // SELECT id, name, pwd, description // FROM users -// WHERE id = ? +// WHERE id = $1 func (q *Queries) GetUserById(ctx context.Context, id int32) (User, error) { - row := q.db.QueryRowContext(ctx, getUserById, id) + row := q.db.QueryRow(ctx, getUserById, id) var i User err := row.Scan( &i.ID, @@ -35,16 +35,16 @@ func (q *Queries) GetUserById(ctx context.Context, id int32) (User, error) { const getUserByName = `-- name: GetUserByName :one SELECT id, name, pwd, description FROM users - WHERE LOWER(name) = LOWER(?) + WHERE LOWER(name) = LOWER($1) ` // GetUserByName // // SELECT id, name, pwd, description // FROM users -// WHERE LOWER(name) = LOWER(?) +// WHERE LOWER(name) = LOWER($1) func (q *Queries) GetUserByName(ctx context.Context, lower string) (User, error) { - row := q.db.QueryRowContext(ctx, getUserByName, lower) + row := q.db.QueryRow(ctx, getUserByName, lower) var i User err := row.Scan( &i.ID, @@ -65,7 +65,7 @@ SELECT id, name, pwd, description // SELECT id, name, pwd, description // FROM users func (q *Queries) GetUsers(ctx context.Context) ([]User, error) { - rows, err := q.db.QueryContext(ctx, getUsers) + rows, err := q.db.Query(ctx, getUsers) if err != nil { return nil, err } @@ -83,9 +83,6 @@ func (q *Queries) GetUsers(ctx context.Context) ([]User, error) { } items = append(items, i) } - if err := rows.Close(); err != nil { - return nil, err - } if err := rows.Err(); err != nil { return nil, err } |