Skip to content

PDOEngine - support Mysql ST_GeomFromWKB axis-order option - #60

Open
YasserB94 wants to merge 2 commits into
brick:mainfrom
YasserB94:pdo-engine-mysql-axis-order
Open

PDOEngine - support Mysql ST_GeomFromWKB axis-order option#60
YasserB94 wants to merge 2 commits into
brick:mainfrom
YasserB94:pdo-engine-mysql-axis-order

Conversation

@YasserB94

@YasserB94 YasserB94 commented Aug 5, 2026

Copy link
Copy Markdown

First: Thank you for this package. This has made the GeoJSON parsing I've had to do a lot quicker and easier!


Problem

Whilst working with an API that only allows Long-Lat axis orders in their GeoJSON I had quite some exceptions as Mysql's default does not accept this as input.

I currently resolved this by making a copy of PDOEngine (since it's final), and adding the option. Though this seems like something that could just be part of the PDOEngine, thus this PR.

I looked through issues and pull requests on a limited amount of keywords and found no matches regarding this.

Changes

  • An optional third parameter mysqlGeoAxisOrder added to PdoEngine defaulting to null
    • When set it is passed to ST_GeomFromWKB according to MySQL's documentation (linked below)
    • It defaults to null, and not to the MySQL default to ensure there are no changes for any existing implementation, and thus this PR should cause no breaking changes

I haven't found any resources on MariaDB supporting this, instead of a runtime version check (I found one the tests) and an extra round tip to the driver, I opted to just put warning comments in the code.

The full test suite including the added ones ran successfully on both MySQL (8.4) and MariaDB (11.4) (On MariaDB the tests get skipped).

TLDR: Adds support for the MySQL axis-order options in ST_GeomFromWKB. No breaking changes, one caveat: there is no runtime check for MariaDB, setting this for a MariaDB database will cause an exception.

Links and Context

I found out about the option here: https://dev.mysql.com/doc/refman/8.0/en/gis-wkb-functions.html
To quote:

By default, geographic coordinates (latitude, longitude) are interpreted as in the order specified by the spatial reference system of geometry arguments. An optional options argument may be given to override the default axis order. options consists of a list of comma-separated key=value. The only permitted key value is axis-order, with permitted values of lat-long, long-lat and srid-defined (the default).

Disclaimers

  • Due to my very limited knowledge of GEO/GIS implementations I used AI to provide tests for my changes.
  • I figured this might be nice to be included in geo, though I have not spent a lot of time to go through the complete codebase, I might be off on some parts regarding code style.

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.92%. Comparing base (cd8abe5) to head (99bc8ec).

Additional details and impacted files
@@             Coverage Diff              @@
##               main      #60      +/-   ##
============================================
+ Coverage     48.76%   48.92%   +0.15%     
- Complexity     2037     2038       +1     
============================================
  Files            75       75              
  Lines          4727     4730       +3     
============================================
+ Hits           2305     2314       +9     
+ Misses         2422     2416       -6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant