-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support nested fields of object type (#404)
### What This PR adds support for selecting nested fields that arise from composite objects. The case for nested fields which are arrays will be treated in a followup PR. ### How * Handling of field selection is now recursive and lives in its own function. * A dedicated case handling nested fields has been added. Each field at each layer of nesting adds another lateral join The SQL generated is of the form ``` /// SELECT /// coalesce(json_agg(row_to_json("%6_rows")), '[]') AS "rows" /// FROM /// ( /// SELECT /// "%3_nested_fields_collect"."collected" AS "result" /// FROM /// <current table> AS "%0_<current table>" /// LEFT OUTER JOIN LATERAL ( /// SELECT /// ("%0_<current table>"."<composite column>").* /// ) AS "%2_nested_field_bound" ON ('true') /// LEFT OUTER JOIN LATERAL ( /// SELECT /// row_to_json("%4_nested_fields") AS "collected" /// FROM /// ( /// SELECT /// "%2_nested_field_bound"."<nested column>" AS "<nested field alias>" /// ) AS "%4_nested_fields" /// ) AS "%3_nested_fields_collect" ON ('true') /// ) AS "%6_rows" ```
- Loading branch information
Showing
14 changed files
with
559 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.