Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Conversation

steve-chavez
Copy link
Member

@steve-chavez steve-chavez commented Aug 3, 2022

soedirgo
soedirgo previously approved these changes Aug 3, 2022
@soedirgo soedirgo self-requested a review August 3, 2022 05:11
@soedirgo soedirgo dismissed their stale review August 3, 2022 05:11

misclick

@soedirgo
Copy link
Member

soedirgo commented Aug 3, 2022

Can you give some background on what .geojson() does? .explain() is simple enough, but how does .geojson() change the response? Does it change only geo columns, leaving all other columns the same? Does it only return geo columns?

Also, does .explain() always return stuff in the same format? Looks like Settings is missing if options= isn't specified?

@steve-chavez
Copy link
Member Author

Can you give some background on what .geojson() does?
but how does .geojson() change the response?

It runs st_asgeojson(postgis func) over the whole row making it follow the structure on https://geojson.org/.

Does it change only geo columns, leaving all other columns the same? Does it only return geo columns?

Changes the geocolumns and all the other columns are stored into the properties key as per the spec. If more than one geometry column exists on the relation, st_asgeojson will only put the first one on the geometry key and the other ones will be put on the properties key(can be later enhaced to put all into a multipolygon geometry). This behavior can be changed with select as one would expect.

Also, does .explain() always return stuff in the same format? Looks like Settings is missing if options= isn't specified?

Depends on the options specified, more options add more json keys. These follow the same format as doing an EXPLAIN (FORMAT JSON). (Note: the format varies across pg versions)

@soedirgo
Copy link
Member

soedirgo commented Aug 3, 2022

Gotcha, I guess for now the return type can be:

  • .explain(): PromiseLike<PostgrestResponse<Record<string, unknown>>>
  • .geojson(): PromiseLike<PostgrestSingleResponse<Record<string, unknown>>>

Also change the docker image to include postgis
@steve-chavez
Copy link
Member Author

@soedirgo Done. Could we make a new release to add these methods to supabase-js v2?

@soedirgo
Copy link
Member

soedirgo commented Aug 4, 2022

Will do! v2 isn't released yet (it's on the next branch) but I'll add the features there as well

@soedirgo soedirgo merged commit c265837 into supabase:master Aug 4, 2022
@github-actions
Copy link

github-actions bot commented Aug 4, 2022

🎉 This PR is included in version 0.38.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@dshukertjr
Copy link
Member

Wow, this seems like a very awesome feature!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants