-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Embedding views with sub-selects #1608
Labels
embedding
resource embedding
Comments
This looks super interesting, converting to JSON and leveraging the Postgres JSON parser is a very smart approach! The tricky part in this query is to get the potentially nested Some notes:
|
wolfgangwalther
added a commit
to wolfgangwalther/postgrest
that referenced
this issue
Dec 10, 2020
resolves PostgREST#1608 Refactors the pfkSourceColumns query to use an intermediate JSON format for parsing. This allows much more robust extraction of source columns.
wolfgangwalther
added a commit
to wolfgangwalther/postgrest
that referenced
this issue
Dec 10, 2020
resolves PostgREST#1608 Refactors the pfkSourceColumns query to use an intermediate JSON format for parsing. This allows much more robust extraction of source columns.
wolfgangwalther
added a commit
that referenced
this issue
Dec 10, 2020
resolves #1608 Refactors the pfkSourceColumns query to use an intermediate JSON format for parsing. This allows much more robust extraction of source columns.
61 tasks
monacoremo
pushed a commit
to monacoremo/postgrest
that referenced
this issue
Jul 17, 2021
resolves PostgREST#1608 Refactors the pfkSourceColumns query to use an intermediate JSON format for parsing. This allows much more robust extraction of source columns.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When embedding views, the following breaks the detection algorithm:
What happens here is:
allSourceColumns
tries to parse the view definition in form of apg_node_tree
(https://www.postgresql.org/docs/current/catalog-pg-rewrite.html)COALESCE
)My current solution is to wrap another
SELECT
around theCOALESCE
- that works fine.I have played a bit with changing up the query in
allSourceColumns
- I think the structure ofpg_node_tree
does not allow a proper regex solution to really get rid of all sub-selects. However, I was able to apply a couple of transformations to the node tree to bring it to JSON format - which can easily be parsed for the embeddable columns. This was only tested with PG12 so far and also not very extensively, yet. (just noted that it fails on some of the pg_catalog views apparently - so there is definitely some more tweaking needed for thetransform_json
part)The query currently looks like this:
In theory this should allow a much more robust parsing of the view definition, but ONLY IF the json transformation works flawlessly.
Just thought I post that here, in case anyone wants to play with this, before I continue to.
The text was updated successfully, but these errors were encountered: