-- name: InsertExamPrepPracticeParent :one INSERT INTO exam_prep.practice_parents (practice_id, parent_kind, parent_id) VALUES ($1, $2, $3) RETURNING *; -- name: DeleteExamPrepPracticeParentsByPracticeID :exec DELETE FROM exam_prep.practice_parents WHERE practice_id = $1; -- name: DeleteExamPrepPracticeParent :execrows DELETE FROM exam_prep.practice_parents WHERE practice_id = $1 AND parent_kind = $2 AND parent_id = $3; -- name: ListExamPrepPracticeParentsByPracticeID :many SELECT * FROM exam_prep.practice_parents WHERE practice_id = $1 ORDER BY id ASC; -- name: ListExamPrepPracticeParentsByPracticeIDs :many SELECT * FROM exam_prep.practice_parents WHERE practice_id = ANY (sqlc.arg('practice_ids')::bigint[]) ORDER BY practice_id ASC, id ASC; -- name: CountExamPrepPracticesByParent :one SELECT COUNT(*)::bigint FROM exam_prep.practice_parents WHERE parent_kind = $1 AND parent_id = $2; -- name: CountExamPrepPracticesByParentExcludingPractice :one SELECT COUNT(*)::bigint FROM exam_prep.practice_parents WHERE parent_kind = $1 AND parent_id = $2 AND practice_id <> $3; -- name: ListExamPrepPracticeParentsByQuestionSetID :many SELECT pp.parent_kind, pp.parent_id, pp.practice_id FROM exam_prep.practice_parents pp INNER JOIN exam_prep.lesson_practices p ON p.id = pp.practice_id WHERE p.question_set_id = $1 ORDER BY p.id DESC, pp.id ASC;