Skip to content

Commit

Permalink
fix: properly delete tables with filtered view
Browse files Browse the repository at this point in the history
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
  • Loading branch information
enjeck committed Feb 14, 2024
1 parent 2e10a44 commit d048383
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/Service/TableService.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,16 @@ public function delete(int $id, ?string $userId = null): Table {
throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage());
}

// delete all views for that table
// we must delete views before columns because we need columns
// while deleting views (in case we're deleting a table that has views)
try {
$this->viewService->deleteAllByTable($item, $userId);
} catch (InternalError|PermissionError $e) {
$this->logger->error($e->getMessage(), ['exception' => $e]);
throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage());
}

// delete all columns for that table
try {
$columns = $this->columnService->findAllByTable($id, null, $userId);
Expand All @@ -386,13 +396,6 @@ public function delete(int $id, ?string $userId = null): Table {
}
}

// delete all views for that table
try {
$this->viewService->deleteAllByTable($item, $userId);
} catch (InternalError|PermissionError $e) {
$this->logger->error($e->getMessage(), ['exception' => $e]);
throw new InternalError(get_class($this) . ' - ' . __FUNCTION__ . ': '.$e->getMessage());
}

// delete all shares for that table
$this->shareService->deleteAllForTable($item);
Expand Down

0 comments on commit d048383

Please sign in to comment.