jsor / doctrine-postgis

Spatial and Geographic Data with PostGIS and Doctrine.
MIT License
209 stars 50 forks source link

AssertionError on ORM Parser.php #59

Closed grogou closed 1 year ago

grogou commented 1 year ago

Hi @jsor and thank you for this repository.

My project is in Symfony 6.2.7 with Doctrine ORM 2.14.1.

I have done setup as you described https://github.com/jsor/doctrine-postgis/blob/main/docs/symfony.md

I have added 2 functions image

This one is my dql query in User repository

public function findByLocationWithinDistance(
    string $locationPoint,
    int    $per_page = 10,
    int    $page = 1,
): ApiPlatformPaginator
{
    $count = $per_page <= 50 ? $per_page : 10;
    $qb = $this->createQueryBuilder('u')
        ->where('ST_DWithin(u.locationPoint::geography, ST_PointFromText(:locationPoint)::geography, :distance)')
        ->setParameter('locationPoint', $locationPoint)
        ->setParameter('distance', 500000)
        ->setFirstResult($count * ($page - 1))
        ->setMaxResults($count)
        ->getQuery();
    return new ApiPlatformPaginator(new Paginator($qb));
}

And this one is standard query, it is doing same thing and it is working on direct execution in pgAdmin

SELECT * FROM "user" as u WHERE ST_DWithin( u.location_point::geography, ST_PointFromText('SRID=4326;POINT(56.321057723568 -105.15506956512)')::geography, 500000)

The error is

{"message":"Uncaught Error: assert($token !== null)","context":{"exception":{"class":"AssertionError","message":"assert($token !== null)","code":1,"file":"/var/www/html/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php:2603"}},"level":500,"level_name":"CRITICAL","channel":"php","datetime":"2023-04-25T11:17:02.599771+00:00","extra":{}}

Is it know issue or new version of symfony or doctrine is not supported?

grogou commented 1 year ago

I have solved this problem with native query, but I guess there is problem with functions, maybe registering string_functions is not working or there is some deprecation.

Sad about responsibility of this repo. It is really good repository.