fix: write geography columns explicitly instead of inferring points from value shape - #506
Merged
Merged
Conversation
…rom value shape
The PointPlugin converted any object with `lat` and `lng` keys into a
PostGIS point before every query. A data source whose records have
columns named `lat` and `lng` therefore had its whole JSON row turned
into `SRID=4326;POINT(...)`, which Postgres rejected for the jsonb
column ("invalid input syntax for type json").
Geometry is no longer inferred from a value's shape. Geography columns
are typed as `GeographyColumn<...>` so their insert/update type is a SQL
expression, and every write goes through `toGeography(point)`. The
plugin now only parses geography values on read. Repositories that
accept a domain object (`upsertDataRecords`, `upsertPlacedMarker`) wrap
the point themselves so callers are unchanged.
Adds a regression test importing a CSV with `lat`/`lng` columns and a
round-trip test for `toGeography`.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…able Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…n comment Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Problem
An Airtable data source whose records have columns named
latandlngfailed to import withinvalid input syntax for type json. The PointPlugin converted any object withlatandlngkeys into a PostGIS point before every query, so the whole JSON row was turned intoSRID=4326;POINT(...)and rejected by thejsonbcolumn. This affects any data source type with those two column names.Fix
Geometry is no longer inferred from a value's shape.
PointPluginnow only parses geography values on read (unchanged behaviour).data_record.geocode_point,placed_marker.point,geocode_cache.point) are typed asGeographyColumn<...>so their insert/update type is a SQL expression. A raw{ lat, lng }object is a type error at the write site.toGeography(point)builds theST_SetSRID(ST_MakePoint(...), 4326)::geographyexpression.upsertDataRecordsandupsertPlacedMarkerwrap the point internally, so callers are unchanged. The two directgeocodeCachewrites wrap it themselves.Tests
tests/feature/geography.test.ts: regression test importing a CSV withlat/lngcolumns, and a round-trip test fortoGeographyon both geography columns.🤖 Generated with Claude Code