query_param_limit
This commit is contained in:
parent
7f21674521
commit
9f340799ac
5 changed files with 10 additions and 34 deletions
|
@ -94,10 +94,7 @@ func passwd(cfg *config.Config, username string) error {
|
|||
|
||||
hashpw, err := bcrypt.GenerateFromPassword([]byte(pw), bcrypt.DefaultCost)
|
||||
|
||||
return database.New(db).UpdatePassword(context.Background(), database.UpdatePasswordParams{
|
||||
Username: username,
|
||||
Password: string(hashpw),
|
||||
})
|
||||
return database.New(db).UpdatePassword(context.Background(), username, string(hashpw))
|
||||
}
|
||||
|
||||
func readPassword(prompt string) (string, error) {
|
||||
|
|
|
@ -88,12 +88,7 @@ const setCallTranscript = `-- name: SetCallTranscript :exec
|
|||
UPDATE calls SET transcript = $2 WHERE id = $1
|
||||
`
|
||||
|
||||
type SetCallTranscriptParams struct {
|
||||
ID pgtype.UUID
|
||||
Transcript pgtype.Text
|
||||
}
|
||||
|
||||
func (q *Queries) SetCallTranscript(ctx context.Context, arg SetCallTranscriptParams) error {
|
||||
_, err := q.db.Exec(ctx, setCallTranscript, arg.ID, arg.Transcript)
|
||||
func (q *Queries) SetCallTranscript(ctx context.Context, iD pgtype.UUID, transcript pgtype.Text) error {
|
||||
_, err := q.db.Exec(ctx, setCallTranscript, iD, transcript)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -86,13 +86,7 @@ INSERT INTO talkgroups_tags(system_id, talkgroup_id, tags) VALUES($1, $2, $3)
|
|||
ON CONFLICT (system_id, talkgroup_id) DO UPDATE SET tags = $3
|
||||
`
|
||||
|
||||
type SetTalkgroupTagsParams struct {
|
||||
SystemID int32
|
||||
TalkgroupID int32
|
||||
Tags []string
|
||||
}
|
||||
|
||||
func (q *Queries) SetTalkgroupTags(ctx context.Context, arg SetTalkgroupTagsParams) error {
|
||||
_, err := q.db.Exec(ctx, setTalkgroupTags, arg.SystemID, arg.TalkgroupID, arg.Tags)
|
||||
func (q *Queries) SetTalkgroupTags(ctx context.Context, systemID int32, talkgroupID int32, tags []string) error {
|
||||
_, err := q.db.Exec(ctx, setTalkgroupTags, systemID, talkgroupID, tags)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -22,14 +22,8 @@ INSERT INTO api_keys(
|
|||
RETURNING id, owner, created_at, expires, disabled, api_key
|
||||
`
|
||||
|
||||
type CreateAPIKeyParams struct {
|
||||
Owner pgtype.Int4
|
||||
Expires pgtype.Timestamp
|
||||
Disabled pgtype.Bool
|
||||
}
|
||||
|
||||
func (q *Queries) CreateAPIKey(ctx context.Context, arg CreateAPIKeyParams) (ApiKey, error) {
|
||||
row := q.db.QueryRow(ctx, createAPIKey, arg.Owner, arg.Expires, arg.Disabled)
|
||||
func (q *Queries) CreateAPIKey(ctx context.Context, owner pgtype.Int4, expires pgtype.Timestamp, disabled pgtype.Bool) (ApiKey, error) {
|
||||
row := q.db.QueryRow(ctx, createAPIKey, owner, expires, disabled)
|
||||
var i ApiKey
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
|
@ -188,12 +182,7 @@ const updatePassword = `-- name: UpdatePassword :exec
|
|||
UPDATE users SET password = $2 WHERE username = $1
|
||||
`
|
||||
|
||||
type UpdatePasswordParams struct {
|
||||
Username string
|
||||
Password string
|
||||
}
|
||||
|
||||
func (q *Queries) UpdatePassword(ctx context.Context, arg UpdatePasswordParams) error {
|
||||
_, err := q.db.Exec(ctx, updatePassword, arg.Username, arg.Password)
|
||||
func (q *Queries) UpdatePassword(ctx context.Context, username string, password string) error {
|
||||
_, err := q.db.Exec(ctx, updatePassword, username, password)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -8,3 +8,4 @@ sql:
|
|||
package: "database"
|
||||
out: "../pkg/gordio/database"
|
||||
sql_package: "pgx/v5"
|
||||
query_parameter_limit: 3
|
||||
|
|
Loading…
Reference in a new issue