diff --git a/app/Models/QueriesModel.php b/app/Models/QueriesModel.php index 5b8316ff2..795af83b8 100644 --- a/app/Models/QueriesModel.php +++ b/app/Models/QueriesModel.php @@ -149,7 +149,7 @@ public function execute(int $id = 0, object $user = null): array $type = end($split3); $sql = str_ireplace('WHERE @filter', "WHERE {$filter}", $sql); } - if (!empty($instance->config->advanced_queries) and $instance->config->advanced_queries and $query->advanced === 'y') { + if (!empty($instance->config->advanced_queries) and $instance->config->advanced_queries and !empty($query->advanced) and $query->advanced === 'y') { $sql = str_ireplace('@orgs', "({$user->org_list})", $sql); }