-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
12 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,14 +103,22 @@ public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null) | |
if ($dataQuery->getQueryParam('SoftDeletable.filter') === false) { | ||
return; | ||
} | ||
// Don't run if querying by ID | ||
if ($query->filtersOnID() && self::config()->check_filters_on_id) { | ||
return; | ||
} | ||
|
||
$froms = $query->getFrom(); | ||
$froms = array_keys($froms); | ||
$tableName = array_shift($froms); | ||
|
||
// Don't run if querying by ID on base table because it's much more convenient | ||
// Don't use filtersOnID as it will return true when filtering a relation by ID as well | ||
if (self::config()->check_filters_on_id) { | ||
foreach ($query->getWhereParameterised($parameters) as $predicate) { | ||
$filtered = str_replace(['"', '`', ' ', 'IN'], ['', '', '', '='], $predicate); | ||
// Where must contain a clause with Table.ID = or Table.ID IN | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
lekoala
Author
Owner
|
||
if (strpos($filtered, $tableName . ".ID=") === 0) { | ||
return; | ||
} | ||
} | ||
} | ||
$query->addWhere("\"$tableName\".\"Deleted\" IS NULL"); | ||
} | ||
|
||
|
@lekoala "must contain" is represented via strpos as
!== false
whereas "Starts with" is represented by=== 0
, so either the comment or the code is inaccurate.