dbal icon indicating copy to clipboard operation
dbal copied to clipboard

Add spatial types

Open ddegasperi opened this issue 4 months ago • 4 comments

Q A
Type feature
Fixed issues #7081

Summary

This PR introduces spatial data type support for DBAL, starting with PostgreSQL/PostGIS and MySQL. This implementation is intended to serve as a reference and guide for adding support for other database platforms in the future.

Core Spatial Types

  • GeometryType (Types::GEOMETRY) - For planar coordinate systems
  • GeographyType (Types::GEOGRAPHY) - For spherical earth coordinates
  • Both types handle GeoJSON format for data exchange

Schema API Integration

  • Extended Column and ColumnEditor with geometryType and srid properties
  • Clean fluent API: Column::editor()->setGeometryType('POINT')->setSrid(4326)
  • Full PostgreSQL platform support with PostGIS-specific SQL generation
  • Schema introspection and table creation/modification support

What's next

  • [ ] Discuss the PR
  • [X] Add other platforms (PostgreSQL/PostGIS, MySQL)
  • [X] Add spatial index (PostgreSQL/PostGIS, MySQL already support creation of spatial indexes)

ddegasperi avatar Aug 18 '25 07:08 ddegasperi

Adding spatial index management would be interesting for this PR I think :).

For instance: CREATE INDEX mytable_geom_x ON mytable USING GIST (geom)

Sources:

  • https://postgis.net/documentation/faq/spatial-indexes/
  • https://postgis.net/workshops/postgis-intro/indexing.html
  • https://postgis.net/docs/using_postgis_dbmanagement.html#build-indexes

tibobaldwin avatar Sep 06 '25 09:09 tibobaldwin

Adding spatial index management would be interesting

Thanks for the advice — I agree, index management is definitely an important aspect when working with geometry data. I haven’t investigated it in depth yet, but it looks like this might already be supported by specifying the index type. A quick search in the repository shows an IndexType enum with a SPATIAL option, so I’ll take a closer look at how that could be integrated here.

ddegasperi avatar Sep 08 '25 06:09 ddegasperi

Wow, that's exactly what I'd like to see integrated into Doctrine soon. Great work!

jungleman12 avatar Nov 16 '25 16:11 jungleman12

Hi @derrabus

I’ve addressed all the feedback received so far and updated the PR accordingly. When you get a chance, could you please let me know if there’s anything else I can do to help move this forward?

Thanks a lot for your time

ddegasperi avatar Dec 05 '25 15:12 ddegasperi

Thank your for all the work you've put into this PR. Your changes look very promising.

Thanks a lot for your review and the detailed feedback! I really appreciate the time you took to go through the PR. I’ll work on the requested changes as soon as possible and hopefully be able to address everything within the next week.

ddegasperi avatar Dec 12 '25 10:12 ddegasperi