diff --git a/src/ORM/Association/BelongsToMany.php b/src/ORM/Association/BelongsToMany.php index e8e8a7e00f9..072c0bcd0f6 100644 --- a/src/ORM/Association/BelongsToMany.php +++ b/src/ORM/Association/BelongsToMany.php @@ -893,7 +893,7 @@ protected function _buildQuery($options) { $assoc = $this->target()->association($name); $query ->join($matching + $joins, [], true) - ->autoFields(empty($query->clause('select'))) + ->autoFields($query->clause('select') === []) ->select($query->aliasFields((array)$assoc->foreignKey(), $name)); $query->eagerLoader()->addToJoinsMap($name, $assoc);