-
Notifications
You must be signed in to change notification settings - Fork 59
Open
Labels
Description
Since Doctrine ORM 2.13+, the TypedExpression interface allows DQL functions to explicitly declare their return types. This enables better type inference in queries and improves the overall developer experience.
Currently, PostGIS functions in this library don't implement TypedExpression, which means:
- No explicit type information in DQL queries
- Potential type mismatches in complex queries
- Missing IDE autocomplete hints for return types
Proposed Changes
Implement TypedExpression on appropriate PostGIS functions to declare their return types explicitly.
Functions returning numeric types (float/integer)
ST_Distance→Types::FLOATST_Length→Types::FLOATST_Area→Types::FLOATST_Perimeter→Types::FLOATST_X→Types::FLOATST_Y→Types::FLOATST_Z→Types::FLOATST_NumGeometries→Types::INTEGERST_NPoints→Types::INTEGERST_SRID→Types::INTEGER
Functions returning boolean types
ST_Contains→Types::BOOLEANST_Within→Types::BOOLEANST_Intersects→Types::BOOLEANST_Crosses→Types::BOOLEANST_Overlaps→Types::BOOLEANST_Touches→Types::BOOLEANST_Disjoint→Types::BOOLEANST_Equals→Types::BOOLEANST_DWithin→Types::BOOLEANST_IsEmpty→Types::BOOLEANST_IsValid→Types::BOOLEAN
Functions returning string types
ST_AsText→Types::STRINGST_AsEWKT→Types::STRINGST_AsGeoJSON→Types::STRINGST_AsGML→Types::STRINGST_AsKML→Types::STRINGST_AsSVG→Types::STRINGST_GeometryType→Types::STRING
Functions returning geometry types
Functions like ST_Buffer, ST_Intersection, ST_Union, etc. could potentially return custom geometry types, but this might require more discussion on the implementation approach.
Implementation Example
final class ST_Distance extends FunctionNode implement TypedExpression
{
// ... existing implementation
public function getReturnType(): Type
{
return Type::getType(Types::FLOAT);
}
}
Doctrine documentation : https://www.doctrine-project.org/projects/doctrine-orm/en/3.5/reference/dql-doctrine-query-language.html