public function execute(): Query
    {
        // query is not filterable, return it as is.
        if (! $this->filterable) {
            return $this->query;
        }

        if ($this->hasFullAccess()) {
            return $this->query;
        }

        $where = $this->getWhereClause();
        if (! empty($where)) {
            // apply all conditions using the OR operator
            $where = ['OR' => $where];
        }

        if (empty($where)) {
            $primaryKey = $this->table->getPrimaryKey();
            Assert::string($primaryKey);

            // if user has neither owner nor full capability on current action then filter out all records
            $where = [$this->table->aliasField($primaryKey) => null];
        }

        $this->query->where($where);

        return $this->query;
    }