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

PostGIS geometry returned as binary in text/csv output when WKT would be expected #3577

Open
bjornharrtell opened this issue Jun 9, 2024 · 3 comments

Comments

@bjornharrtell
Copy link

bjornharrtell commented Jun 9, 2024

Environment

  • PostgreSQL version: 12
  • PostgREST version: postgrest/postgrest:v12.0.2
  • Operating system:

Description of issue

PostGIS geometry is returned as some kind of binary string encoding when client has requested text/csv output. In standard json output it is GeoJSON which is logical and expected. In text/csv I would expect WKT representation (see https://postgis.net/docs/manual-3.4/ST_AsText.html).

@laurenceisla
Copy link
Member

What's the exact request and response you're getting? An example using curl -i '<your-url>' would be great to better pinpoint the issue.

Perhaps this has to do with Media Type Handlers, in particular the example about overriding the text/csv handler?

@bjornharrtell
Copy link
Author

@laurenceisla mabye I can use that feature to customize the output? But I'm not sure the binary string encoding is useful for anyone as the default. You can actually see example output of geometry in the example athttps://postgrest.org/en/latest/references/api/media_type_handlers.html#overriding-a-builtin-handler because it doesn't do any transformation of the geom field:

image

@wolfgangwalther
Copy link
Member

What we would need here: Mediatype-specific domain representations.

Currently the output format for a single column can be changed with domain representations. But those always map to json - but here we are looking at csv. We don't want to replace the full csv parser, though - we just want the output format for a single column to change.

We don't have this, yet, but analogous to domain reps, we'd need a cast from the <postgis-type> to text/csv to be detected by postgrest.

I needed this in a similar case, too. Not postgis, but some other column type converted to text/csv.

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

No branches or pull requests

3 participants