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)
|
hashpw, err := bcrypt.GenerateFromPassword([]byte(pw), bcrypt.DefaultCost)
|
||||||
|
|
||||||
return database.New(db).UpdatePassword(context.Background(), database.UpdatePasswordParams{
|
return database.New(db).UpdatePassword(context.Background(), username, string(hashpw))
|
||||||
Username: username,
|
|
||||||
Password: string(hashpw),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func readPassword(prompt string) (string, error) {
|
func readPassword(prompt string) (string, error) {
|
||||||
|
|
|
@ -88,12 +88,7 @@ const setCallTranscript = `-- name: SetCallTranscript :exec
|
||||||
UPDATE calls SET transcript = $2 WHERE id = $1
|
UPDATE calls SET transcript = $2 WHERE id = $1
|
||||||
`
|
`
|
||||||
|
|
||||||
type SetCallTranscriptParams struct {
|
func (q *Queries) SetCallTranscript(ctx context.Context, iD pgtype.UUID, transcript pgtype.Text) error {
|
||||||
ID pgtype.UUID
|
_, err := q.db.Exec(ctx, setCallTranscript, iD, transcript)
|
||||||
Transcript pgtype.Text
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) SetCallTranscript(ctx context.Context, arg SetCallTranscriptParams) error {
|
|
||||||
_, err := q.db.Exec(ctx, setCallTranscript, arg.ID, arg.Transcript)
|
|
||||||
return err
|
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
|
ON CONFLICT (system_id, talkgroup_id) DO UPDATE SET tags = $3
|
||||||
`
|
`
|
||||||
|
|
||||||
type SetTalkgroupTagsParams struct {
|
func (q *Queries) SetTalkgroupTags(ctx context.Context, systemID int32, talkgroupID int32, tags []string) error {
|
||||||
SystemID int32
|
_, err := q.db.Exec(ctx, setTalkgroupTags, systemID, talkgroupID, tags)
|
||||||
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)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,14 +22,8 @@ INSERT INTO api_keys(
|
||||||
RETURNING id, owner, created_at, expires, disabled, api_key
|
RETURNING id, owner, created_at, expires, disabled, api_key
|
||||||
`
|
`
|
||||||
|
|
||||||
type CreateAPIKeyParams struct {
|
func (q *Queries) CreateAPIKey(ctx context.Context, owner pgtype.Int4, expires pgtype.Timestamp, disabled pgtype.Bool) (ApiKey, error) {
|
||||||
Owner pgtype.Int4
|
row := q.db.QueryRow(ctx, createAPIKey, owner, expires, disabled)
|
||||||
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)
|
|
||||||
var i ApiKey
|
var i ApiKey
|
||||||
err := row.Scan(
|
err := row.Scan(
|
||||||
&i.ID,
|
&i.ID,
|
||||||
|
@ -188,12 +182,7 @@ const updatePassword = `-- name: UpdatePassword :exec
|
||||||
UPDATE users SET password = $2 WHERE username = $1
|
UPDATE users SET password = $2 WHERE username = $1
|
||||||
`
|
`
|
||||||
|
|
||||||
type UpdatePasswordParams struct {
|
func (q *Queries) UpdatePassword(ctx context.Context, username string, password string) error {
|
||||||
Username string
|
_, err := q.db.Exec(ctx, updatePassword, username, password)
|
||||||
Password string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *Queries) UpdatePassword(ctx context.Context, arg UpdatePasswordParams) error {
|
|
||||||
_, err := q.db.Exec(ctx, updatePassword, arg.Username, arg.Password)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,3 +8,4 @@ sql:
|
||||||
package: "database"
|
package: "database"
|
||||||
out: "../pkg/gordio/database"
|
out: "../pkg/gordio/database"
|
||||||
sql_package: "pgx/v5"
|
sql_package: "pgx/v5"
|
||||||
|
query_parameter_limit: 3
|
||||||
|
|
Loading…
Reference in a new issue