Conversation
Polygon::set() returned the bare Polygon object for typed geometries while Point and MultiPolygon wrap them in SpatialExpression. Laravel re-runs class casts during getAttributes(), which overwrote the SpatialExpression prepared by SpatialTrait::performInsert() — so the raw geometry was bound to the query and MySQL rejected the write with error 1416 (Cannot get geometry object from data you send to the GEOMETRY field). This broke zone creation, e.g. in the FleetOps testing seeders.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Casts\Polygon::set()returned the barePolygonobject for typed geometries, whilePointandMultiPolygonwrap theirs inSpatialExpression.Because Laravel re-runs class casts during
getAttributes()(mergeAttributesFromClassCasts), the secondset()call overwrote theSpatialExpressionthatSpatialTrait::performInsert()had prepared — so the rawPolygonobject was bound to the query, PDO stringified it to(lng lat, ...), and MySQL rejected the write:Hit this running the FleetOps testing seeders (
NetworkSeeder→zones.border) against the bundled MySQL 8 container. The same path breaks Zone creation through the API.Changes
Casts\Polygon::set()now returnsnew SpatialExpression($value)forSpatialPolygonandGeometryInterfaceinputs, mirroringMultiPolygonexactly (the GeoJSON andSpatialExpressionbranches are unchanged — non-object inputs never enter the cast cache, so the geometry-object return there is still correct).SpatialCastBranchesTestwhich previously asserted the old hand-back-the-object behavior; it now expects aSpatialExpressionlike the other casts.Test plan
db:seed --class="Fleetbase\FleetOps\Seeders\Testing\TestingSeeder"completes on a fresh Docker install (was failing on zone insert)