fix(tester): fix schema&queries
This commit is contained in:
parent
dd87d63860
commit
ffacc9e3ac
2 changed files with 11 additions and 8 deletions
|
@ -67,13 +67,16 @@ func (r *ContestRepository) DeleteContest(ctx context.Context, id int32) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
const addTaskQuery = "INSERT INTO tasks (problem_id, contest_id, position) VALUES (?, ?,COALESCE(SELECT MAX(position) FROM task WHERE contest_id = ? ,0) + 1) RETURNING id"
|
||||
const addTaskQuery = `INSERT INTO tasks (problem_id, contest_id, position)
|
||||
VALUES (?, ?, COALESCE((SELECT MAX(position) FROM tasks WHERE contest_id = ?), 0) + 1)
|
||||
RETURNING id
|
||||
`
|
||||
|
||||
func (r *ContestRepository) AddTask(ctx context.Context, contestId int32, problem_id int32) (int32, error) {
|
||||
func (r *ContestRepository) AddTask(ctx context.Context, contestId int32, problemId int32) (int32, error) {
|
||||
const op = "ContestRepository.AddTask"
|
||||
|
||||
query := r.db.Rebind(addTaskQuery)
|
||||
rows, err := r.db.QueryxContext(ctx, query, problem_id, contestId, contestId)
|
||||
rows, err := r.db.QueryxContext(ctx, query, problemId, contestId, contestId)
|
||||
if err != nil {
|
||||
return 0, handlePgErr(err, op)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue