Skip to content

Error Converting Criteria Object to Doctrine Object #2

@fredpalas

Description

@fredpalas

Making a query on Doctrine using your Library I found this error:

TypeError : Doctrine\Common\Collections\Criteria::Doctrine\Common\Collections\{closure}(): Argument #1 ($ordering) must be of type Doctrine\Common\Collections\Order|string, CodelyTv\Criteria\OrderType given
 /var/www/vendor/doctrine/collections/src/Criteria.php:203
 /var/www/vendor/doctrine/collections/src/Criteria.php:202
 /var/www/vendor/doctrine/collections/src/Criteria.php:89
 /var/www/vendor/codelytv/criteria-to-doctrine/src/CriteriaToDoctrineConverter.php:24
 /var/www/src/Shared/Infrastructure/Persistence/DoctrineRepository.php:19
 /var/www/tests/Integration/Blog/Post/Infrastructure/Persistence/PostDoctrineRepositoryTest.php:100
 /var/www/tests/InfrastructureTestCase.php:45
 /var/www/tests/InfrastructureTestCase.php:53
 /var/www/tests/InfrastructureTestCase.php:53
 /var/www/tests/InfrastructureTestCase.php:53
 /var/www/tests/InfrastructureTestCase.php:53
 /var/www/tests/InfrastructureTestCase.php:53
 /var/www/tests/Integration/Blog/Post/Infrastructure/Persistence/PostDoctrineRepositoryTest.php:99

Line 63 of \CodelyTv\Criteria\Doctrine\CriteriaToDoctrineConverter

private function formatOrder(Criteria $criteria): ?array
{
	if (!$criteria->hasOrder()) {
		return null;
	}

	return [$this->mapOrderBy($criteria->order()->orderBy()) => $criteria->order()->orderType()];
}

Should be

private function formatOrder(Criteria $criteria): ?array
{
	if (!$criteria->hasOrder()) {
		return null;
	}

	return [$this->mapOrderBy($criteria->order()->orderBy()) => $criteria->order()->orderType()->value];
}

The enum OrderType is not converted to string

My version of doctrine

Image

"doctrine/doctrine-bundle": "^2.13",
"doctrine/doctrine-migrations-bundle": "^3.4",
"doctrine/orm": "^3.3"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions