Selecto.Builder.Subselect (Selecto v0.3.14)

SQL generation logic for Subselect functionality.

This module handles the construction of correlated subqueries that return aggregated data from related tables as JSON arrays, PostgreSQL arrays, or other aggregate formats.

Link to this section Summary

Link to this section Functions

Link to this function

build_correlated_subquery(selecto, subselect_config)

Build the correlated subquery that fetches related data.

Link to this function

build_correlated_subquery(selecto, subselect_config, source_alias)

Link to this function

build_single_subselect(selecto, subselect_config)

Build a single correlated subquery for a subselect configuration.

Link to this function

build_single_subselect(selecto, subselect_config, source_alias)

Link to this function

build_subselect_clauses(selecto)

@spec build_subselect_clauses(Selecto.Types.t()) ::
  {[Selecto.Types.iodata_with_markers()], Selecto.Types.sql_params()}

Build subselect clauses for the SELECT portion of the query.

Returns a list of SQL fragments that can be included in the main SELECT clause. Each subselect becomes a correlated subquery that aggregates related data.

Link to this function

build_subselect_clauses(selecto, source_alias)

Link to this function

resolve_join_condition(selecto, target_schema)

@spec resolve_join_condition(Selecto.Types.t(), atom()) ::
  {:ok, {String.t(), String.t()}} | {:error, String.t()}

Resolve the join condition needed to correlate the subquery with the main query.

Link to this function

resolve_join_condition_with_path(selecto, target_schema)

@spec resolve_join_condition_with_path(Selecto.Types.t(), atom()) ::
  {:ok, Selecto.Types.iodata_with_markers()} | {:error, String.t()}
Link to this function

resolve_join_condition_with_path(selecto, target_schema, source_alias)

@spec resolve_join_condition_with_path(Selecto.Types.t(), atom(), String.t()) ::
  {:ok, Selecto.Types.iodata_with_markers()} | {:error, String.t()}
Link to this function

wrap_in_aggregation(subquery_iodata, subquery_params, format, config)

Wrap subquery results in the appropriate aggregation function.