twpayne / go-geom

Package geom implements efficient geometry types for geospatial applications.
BSD 2-Clause "Simplified" License
854 stars 106 forks source link

MultiLineStringZ & sqlc interaction #256

Closed bastiankoetsier closed 2 months ago

bastiankoetsier commented 2 months ago

Hey there, first of all thank you for your amazing library!

I do have a question regarding a very specific scenario: My Column in my postgres/postgis db is a geometry(MultiLineStringZ, 25833) and I trying to use sqlc to generate my db code by overriding the specific type for this column with your MultiLineString typew provided by this package. Unfortunately, sqlc does not seem to understand this 😞 For my limited understanding of postgis so far, this should be working but I might be totally off here 😅 Any hints are appreciated!

Greetings from Berlin!

twpayne commented 2 months ago

Can you provide a minimal example (with code) that demonstrates the problem?

bastiankoetsier commented 2 months ago

(thanks for the swift reply!) I tried to follow this https://docs.sqlc.dev/en/latest/reference/datatypes.html#using-github-com-twpayne-go-geom SCR-20240904-lmsw

The schema is super big but this is basically the column definition: geometry(MultiLineStringZ, 25833) When I try to run the query I get

 can't scan into dest[22]: cannot scan NULL into *geom.MultiPolygon

Let me know if you need any other info!

bastiankoetsier commented 2 months ago

okay, I trimmed it down to only one column that gets returned. Now I am getting: can't scan into dest[0]: cannot scan unknown type (OID 83165) in text format into *geom.MultiPolygon

twpayne commented 2 months ago

You are calling github.com/twpayne/pgx-geom.Register, right?

bastiankoetsier commented 2 months ago

yeah of course not .... 🙈 After I figured out I need only single Polygon instead of the multi-variant, it was working as expected. Thank you very much for your help, highly appreciated!