generative placeholders 4 quiz updating
This commit is contained in:
parent
b16aea3f15
commit
e5ba6630d6
@ -389,29 +389,35 @@ func (r *QuizRepository) UpdateQuiz(ctx context.Context, accountId string, recor
|
|||||||
var params []interface{}
|
var params []interface{}
|
||||||
|
|
||||||
if record.Name != "" {
|
if record.Name != "" {
|
||||||
query += ` name = $1,`
|
query += ` name = $%d,`
|
||||||
params = append(params, record.Name)
|
params = append(params, record.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if record.Description != "" {
|
if record.Description != "" {
|
||||||
query += ` description = $2::text,`
|
query += ` description = $%d::text,`
|
||||||
params = append(params, record.Description)
|
params = append(params, record.Description)
|
||||||
}
|
}
|
||||||
|
|
||||||
if record.Status != "" {
|
if record.Status != "" {
|
||||||
query += ` status = $3,`
|
query += ` status = $%d,`
|
||||||
params = append(params, record.Status)
|
params = append(params, record.Status)
|
||||||
}
|
}
|
||||||
|
|
||||||
if record.Config != "" {
|
if record.Config != "" {
|
||||||
query += ` config = $4::text,`
|
query += ` config = $%d::text,`
|
||||||
params = append(params, record.Config)
|
params = append(params, record.Config)
|
||||||
}
|
}
|
||||||
|
|
||||||
query += ` group_id = $5, version = $6 WHERE id = $7 AND accountid = $8`
|
query += ` group_id = $%d, version = $%d WHERE id = $%d AND accountid = $%d`
|
||||||
|
|
||||||
params = append(params, record.GroupId, record.Version, record.Id, accountId)
|
params = append(params, record.GroupId, record.Version, record.Id, accountId)
|
||||||
|
var placeholders []any
|
||||||
|
for i:=1;i<=len(params);i++ {
|
||||||
|
placeholders = append(placeholders, i)
|
||||||
|
}
|
||||||
|
|
||||||
|
query = fmt.Sprintf(query, placeholders...)
|
||||||
|
|
||||||
_, err := r.pool.ExecContext(ctx, query, params...)
|
_, err := r.pool.ExecContext(ctx, query, params...)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user