зеркало из https://github.com/nextcloud/forms.git
Properly delete Answers
Signed-off-by: Jonas Rittershofer <jotoeri@users.noreply.github.com>
This commit is contained in:
Родитель
ab7809b5f4
Коммит
a7aecac31f
|
@ -895,7 +895,7 @@ class ApiController extends Controller {
|
|||
}
|
||||
|
||||
// Delete submission (incl. Answers)
|
||||
$this->submissionMapper->delete($submission);
|
||||
$this->submissionMapper->deleteById($id);
|
||||
|
||||
return new DataResponse($id);
|
||||
}
|
||||
|
|
|
@ -107,6 +107,27 @@ class SubmissionMapper extends QBMapper {
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete the Submission, including answers.
|
||||
* @param int $id of the submission to delete
|
||||
*/
|
||||
public function deleteById(int $id): void {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
|
||||
// First delete corresponding answers.
|
||||
$submissionEntity = $this->findById($id);
|
||||
$this->answerMapper->deleteBySubmission($submissionEntity->getId());
|
||||
|
||||
//Delete Submission
|
||||
$qb->delete($this->getTableName())
|
||||
->where(
|
||||
$qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
|
||||
);
|
||||
|
||||
$qb->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all Submissions corresponding to form, including answers.
|
||||
* @param int $formId
|
||||
*/
|
||||
public function deleteByForm(int $formId): void {
|
||||
|
|
Загрузка…
Ссылка в новой задаче