- 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:
		
							parent
							
								
									bfddf84564
								
							
						
					
					
						commit
						9556dea849
					
				| @ -59,7 +59,7 @@ class MysqlQueryBuilder extends SqlQueryBuilder | ||||
|             $this->push($select); | ||||
|         } | ||||
| 
 | ||||
|         $select->distinct = $distinct; | ||||
|         $select->distinct = $select->distinct || $distinct; | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
|  | ||||
| @ -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}"); | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user