- Fixed a bug where withJoin() would mess with previous select() done on querybuilding

- Fixed a problem related with distinct in select whenever another select on fields was done
This commit is contained in:
Dave Mc Nicoll committed 2025-03-20 17:31:19 +00:00
1 parent bfddf84564
commit 9556dea849
2 files changed
+7 -4

No files matched your search

+1 -1
View File
@@ -59,7 +59,7 @@ class MysqlQueryBuilder extends SqlQueryBuilder
$this->push($select);
}
$select->distinct = $distinct;
$select->distinct = $select->distinct || $distinct;
return $this;
}
+6 -3
View File
@@ -407,7 +407,9 @@ class Repository implements RepositoryInterface
public function withJoin(string|array $fields, array $options = []) : self
{
if ( null === $this->queryBuilder->getFragment(Query\Select::class) ) {
$canSelect = null === $this->queryBuilder->getFragment(Query\Select::class);
if ( $canSelect ) {
$select = $this->entityResolver->fieldList(EntityResolver::KEY_COLUMN_NAME, true);
$this->select($this->entityClass::fields(array_map(fn($f) => $f['object']->name ?? $f['name'], $select)));
}
@@ -442,8 +444,9 @@ class Repository implements RepositoryInterface
$name = $entity::resolveEntity()->searchFieldAnnotation($field->name, [ Field::class ])->name ?? $field->name;
$this->select("$escAlias.$fieldName as $alias\${$name}");
if ($canSelect) {
$this->select("$escAlias.$fieldName as $alias\${$name}");
}
}
}