Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.x] Use cast instead of trait #66

Merged
merged 33 commits into from
Dec 27, 2024
Merged

[2.x] Use cast instead of trait #66

merged 33 commits into from
Dec 27, 2024

Conversation

saibotk
Copy link
Member

@saibotk saibotk commented Dec 27, 2023

This PR introduces several breaking changes.
We mainly switched from using a trait to a more native Laravel approach of using a GeometryCast.
This simplifies many things and is easier to use.

Breaking Changes

  • The HasPostgisColumns trait and $postgisColumns property have been removed.
  • The GeometryWKBCast has been removed.
  • Automatic SRID transformation has been removed.

Additions

  • Introduced GeometryCast to handle geometry casting, replacing the GeometryWKBCast.

Removals

  • The magellan:update-postgis-columns command has been removed.
  • The magellan.eloquent and magellan.model_directories configurations have been removed.

@saibotk saibotk self-assigned this Dec 27, 2023
When using numeric values for the SRID in functions like `ST_Transform`, the query will throw an error that it cannot parse the SRID projection.

This seems to be caused by the PDO driver, which internally always converts parameters to strings.
See https://stackoverflow.com/questions/66625661/cannot-bind-value-as-int-with-pdo-pgsql-driver

We now append a `::int` cast to numeric SRID parameters, so they work as expected again.

For Closures and Expressions, the developer needs to take care of this. We added a note to make them aware of this behavior.
@saibotk saibotk marked this pull request as ready for review December 27, 2024 19:55
@saibotk saibotk changed the title [2.x] Use explicit casters & add asGeojson ST function [2.x] Use cast instead of trait Dec 27, 2024
@saibotk saibotk requested a review from studnitz December 27, 2024 20:04
@saibotk saibotk merged commit a73317b into main Dec 27, 2024
35 checks passed
@saibotk saibotk deleted the caster-everywhere branch December 27, 2024 21:30
@ahawlitschek ahawlitschek restored the caster-everywhere branch January 3, 2025 13:37
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.

3 participants