- Select now only query existing entity's fields on select() and withJoin() statements.

This commit is contained in:
Dave Mc Nicoll committed 2023-01-27 15:46:16 +00:00
1 parent 70021d829d
commit 88e9f048db
2 files changed
+12 -5

No files matched your search

+4 -2
View File
@@ -586,7 +586,8 @@ class Repository
public function withJoin(string|array $fields) : self
{
if ( null === $this->queryBuilder->getFragment(Query\Select::class) ) {
$this->select("{$this->alias}.*");
$select = $this->entityResolver->fieldList(EntityResolver::KEY_COLUMN_NAME, true);
$this->select($this->entityClass::fields(array_map(fn($f) => $f['object']->name ?? $f['name'], $select)));
}
# @TODO Apply FILTER annotation to this too !
@@ -898,7 +899,8 @@ class Repository
protected function selectSqlQuery() : self
{
if ( null === $this->queryBuilder->getFragment(Query\Select::class) ) {
$this->select("{$this->alias}.*");
$fields = $this->entityResolver->fieldList(EntityResolver::KEY_COLUMN_NAME, true);
$this->select($this->entityClass::fields(array_map(fn($f) => $f['object']->name ?? $f['name'], $fields)));
}
if ( null === $this->queryBuilder->getFragment(Query\From::class) ) {