Skip to content

Commit

Permalink
BUGFIX: Only delete unlocalised table record when no base record exists.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpenny committed Oct 25, 2018
1 parent 840e737 commit 961c6e8
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Extension/FluentExtension.php
Expand Up @@ -449,7 +449,24 @@ public function updateDeleteTables(&$queriedTables)

// If table isn't localised, simple delete
if (!isset($localisedTables[$table])) {
$rootDelete->execute();
$baseTable = $this->getDeleteTableTarget($this->owner->baseTable());

// The base table isn't localised? Delete the record then.
if ($baseTable === $rootTable) {
$rootDelete->execute();
continue;
}

$rootDelete
->setDelete("\"{$rootTable}\"")
->addLeftJoin(
$baseTable,
"\"{$rootTable}\".\"ID\" = \"{$baseTable}\".\"ID\""
)
// Only when join matches no localisations is it safe to delete
->addWhere("\"{$baseTable}\".\"ID\" IS NULL")
->execute();

continue;
}

Expand Down

0 comments on commit 961c6e8

Please sign in to comment.