diff --git a/Traits/QueryTrait.php b/Traits/QueryTrait.php index deca613..941dc04 100644 --- a/Traits/QueryTrait.php +++ b/Traits/QueryTrait.php @@ -401,7 +401,7 @@ abstract class QueryTrait extends Component implements ActiveQueryInterface, ISq public function from(string|Closure $tableName): static { if ($tableName instanceof Closure) { - $this->from = $this->makeClosureFunction($tableName); + $this->from = '(' . $this->makeClosureFunction($tableName) . ')'; } else if (class_exists($tableName)) { $this->from = (new $tableName)->getTable(); } else {