Having following error:
"[Syntax Error] line 0, col -1: Error: Expected =, <, <=, <>, >, >=, !=, got end of string."
building this query with doctrine querybuiler :
SELECT *
FROM area
WHERE ST_Contains(polygon, ST_GeomFromText('POINT(13.405584 52.510621)', 1));
(Sf4 and Doctrine 2.6)
Orm config:
orm:
dql:
numeric_functions:
ST_Contains: CrEOF\Spatial\ORM\Query\AST\Functions\MySql\STContains
ST_GeomFromText: App\Infrastructure\Persistence\Doctrine\STGeomFromText
POINT: CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Point
STGeoFromText Class:
use CrEOF\Spatial\ORM\Query\AST\Functions\AbstractSpatialDQLFunction;
class STGeomFromText extends AbstractSpatialDQLFunction
{
protected $platforms = array('mysql');
protected $functionName = 'ST_GeomFromText';
protected $minGeomExpr = 1;
protected $maxGeomExpr = 2;
}
Construction of the query:
use CrEOF\Spatial\PHP\Types\Geometry\Point;
$lon = 13.405584;
$lat = 52.510621;
$qb = $this->getEntityManager()->createQueryBuilder();
$qb->select('a.name')
->from(Area::class, 'a')
->where("ST_Contains(a.polygon, ST_GeomFromText(':point', 1))")
->setParameter('point', new Point($lon, $lat), 'point');
$result = $query->getResult();
same error with:
->where("ST_Contains(a.polygon, ST_GeomFromText(:point, 1))")
notice no presence of symbol ' wrapping the :point parameter.
The error comes from Doctrine/ORM/Query/Parser.php, which tries to parse and validate the query build.
The issue is caused by the parser not "understanding" that ST_Contains returns a boolean value and expects a comparisor operator which could one of the following "=, <, <=, <>, >, >=, !=".
To overcome this, add
= true
to your condition: