Repository navigation
Conversation
`IDBConnection::dropTable()` already adds the table prefix, so passing the prefixed name made it drop a non-existing table and left the test tables in place. Running the repository tests a second time against the same database then failed because the tables already existed. Assisted-by: ClaudeCode:claude-opus-5-5
The find and delete methods of `Repository` only accepted mapped columns as criteria. Using a relation property, e.g. `findBy(['merchant' => $m])` for a ManyToOne relation, failed with a TypeError, so there was no way to query entities by their related entity. The owning side of a relation (ManyToOne, or OneToOne with a JoinColumn) now matches on its join column and accepts the related entity, its primary key, null or a list of those. Properties that can not be used as criteria now throw an `InvalidArgumentException` with a helpful message. Assisted-by: ClaudeCode:claude-opus-5-5
The find methods only support equality conditions, and the hydration of the results is private. So repositories had no way to run queries like range conditions on a date column and still get hydrated entities with their relations resolved, which blocks moving such mappers to the ORM. Add three protected methods: `getSelectQueryBuilder()` returns the select query with the relations joined, filtered and sorted like `findBy()`, so it can be extended with custom conditions. `findEntities()` and `findEntity()` run such a query and hydrate the result. Assisted-by: ClaudeCode:claude-opus-5-5
susnux
marked this pull request as ready for review
November 16, 2026 12:43
susnux
requested review from
CarlSchwan,
come-nc,
leftybournes and
salmart-dev
and removed request for
a team
November 16, 2026 12:43
come-nc
approved these changes
Nov 17, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two gaps in
OCP\AppFramework\ORM\Repositoryblock apps from moving mappers with relationsor non-equality queries to the ORM.
Relations as criteria
The find and delete methods only accepted mapped columns as criteria. Passing a relation
property, e.g.
findBy(['merchant' => $merchant])for aManyToOne, failed with aTypeError.The owning side of a relation (
ManyToOne, orOneToOnewith aJoinColumn) now matches onits join column in
findBy(),findOneBy(),findByAfterId(),findByBeforeId()anddeleteBy().It accepts the related entity, its primary key,
null, or a list of entities / primary keys:Unsupported properties (unknown, or the inverse
mappedByside), unsaved related entities andentities of the wrong class now throw an
InvalidArgumentExceptionwith a clear message.Custom select queries
The hydration of query results was private, so a repository could not run e.g. a date range
query and still get entities with their relations resolved. New protected methods:
getSelectQueryBuilder(array $criteria = [], array $orderBy = []): IQueryBuilderreturns theselect query with all relations joined, filtered and sorted like
findBy(). The entity's tableis aliased as
e.findEntities(IQueryBuilder $query): \Generatorruns it and hydrates all results.findEntity(IQueryBuilder $query): objectruns it and hydrates the single result, throwingDoesNotExistException/MultipleObjectsReturnedException.$qb = $this->getSelectQueryBuilder(['merchant' => $merchant], ['createdAt' => \SortDirection::Ascending]);
$qb->andWhere($qb->expr()->gte('e.created_at', $qb->createNamedParameter($since, IQueryBuilder::PARAM_DATETIME_IMMUTABLE)));
return iterator_to_array($this->findEntities($qb), false);
Checklist
3. to review, feature component)stable32)AI (if applicable)