fn query_no_window(
        &self,
        entities: &Vec<(&Table, Option<QueryFilter>)>,
        mut out: AstPass<Pg>,
    ) -> QueryResult<()> {
        // We have multiple tables which might have different schemas since
        // the entity_types come from implementing the same interface. We
        // need to do the query in two steps: first we build a CTE with the
        // id's of entities matching the filter and order/limit. As a second
        // step, we get matching rows from the underlying tables and convert
        // them to JSONB.
        //
        // Overall, we generate a query
        //
        // with matches as (
        //   select '...' as entity, id, vid, {sort_key}
        //     from {table} c
        //    where {query_filter}
        //    union all
        //    ...
        //    order by {sort_key}
        //    limit n offset m)
        // select m.entity, to_jsonb(c.*) as data, c.id, c.{sort_key}
        //   from {table} c, matches m
        //  where c.vid = m.vid and m.entity = '...'
        //  union all
        //  ...
        //  order by c.{sort_key}

        // Step 1: build matches CTE
        out.push_sql("with matches as (");
        for (i, (table, filter)) in entities.iter().enumerate() {
            if i > 0 {
                out.push_sql("\nunion all\n");
            }
            // select '..' as entity,
            //        c.id,
            //        c.vid,
            //        c.${sort_key}
            out.push_sql("select '");
            out.push_sql(&table.object);
            out.push_sql("' as entity, c.id, c.vid");
            self.sort_key.select(&mut out)?;
            self.filtered_rows(table, filter, out.reborrow())?;
        }
        out.push_sql("\n ");
        self.sort_key.order_by(&mut out)?;
        self.limit(&mut out);

        out.push_sql(")\n");

        // Step 2: convert to JSONB
        for (i, (table, _)) in entities.iter().enumerate() {
            if i > 0 {
                out.push_sql("\nunion all\n");
            }
            out.push_sql("select m.entity, to_jsonb(c.*) as data, c.id");
            self.sort_key.select(&mut out)?;
            out.push_sql("\n  from ");
            out.push_sql(table.qualified_name.as_str());
            out.push_sql(" c,");
            out.push_sql(" matches m");
            out.push_sql("\n where c.vid = m.vid and m.entity = ");
            out.push_bind_param::<Text, _>(&table.object)?;
        }
        out.push_sql("\n ");
        self.sort_key.order_by(&mut out)?;
        Ok(())
    }
/// No windowing, but multiple entity types
No windowing, but multiple entity types
No windowing but multiple entity types
fn query_no_window(
        &self,
        entities: &Vec<(&Table, Option<QueryFilter>)>,
        mut out: AstPass<Pg>,
    ) -> QueryResult<()> {
        // We have multiple tables which might have different schemas since
        // the entity_types come from implementing the same interface. We
        // need to do the query in two steps: first we build a CTE with the
        // id's of entities matching the filter and order/limit. As a second
        // step, we get matching rows from the underlying tables and convert
        // them to JSONB.
        //
        // Overall, we generate a query
        //
        // with matches as (
        //   select '...' as entity, id, vid, {sort_key}
        //     from {table} c
        //    where {query_filter}
        //    union all
        //    ...
        //    order by {sort_key}
        //    limit n offset m)
        // select m.entity, to_jsonb(c.*) as data, c.id, c.{sort_key}
        //   from {table} c, matches m
        //  where c.vid = m.vid and m.entity = '...'
        //  union all
        //  ...
        //  order by c.{sort_key}
        // Step 1: build matches CTE
        out.push_sql("with matches as (");
        for (i, (table, filter)) in entities.iter().enumerate() {
            if i > 0 {
                out.push_sql("\nunion all\n");
            }
            // select '..' as entity,
            //        c.id,
            //        c.vid,
            //        c.${sort_key}
            out.push_sql("select '");
            out.push_sql(&table.object);
            out.push_sql("' as entity, c.id, c.vid");
            self.sort_key.select(&mut out)?;
            self.filtered_rows(table, filter, out.reborrow())?;
        }
        out.push_sql("\n ");
        self.sort_key.order_by(&mut out)?;
        self.limit(&mut out);
        out.push_sql(")\n");
        // Step 2: convert to JSONB
        for (i, (table, _)) in entities.iter().enumerate() {
            if i > 0 {
                out.push_sql("\nunion all\n");
            }
            out.push_sql("select m.entity, to_jsonb(c.*) as data, c.id");
            self.sort_key.select(&mut out)?;
            out.push_sql("\n  from ");
            out.push_sql(table.qualified_name.as_str());
            out.push_sql(" c,");
            out.push_sql(" matches m");
            out.push_sql("\n where c.vid = m.vid and m.entity = ");
            out.push_bind_param::<Text, _>(&table.object)?;
        }
        out.push_sql("\n ");
        self.sort_key.order_by(&mut out)?;
        Ok(())
    }
fn query_no_window ( & self , entities : & Vec < ( & Table , Option < QueryFilter > ) > , mut out : AstPass < Pg > , ) -> QueryResult < ( ) > { // We have multiple tables which might have different schemas since // the entity_types come from implementing the same interface. We // need to do the query in two steps: first we build a CTE with the // id's of entities matching the filter and order/limit. As a second // step, we get matching rows from the underlying tables and convert // them to JSONB. // // Overall, we generate a query // // with matches as ( //   select '...' as entity, id, vid, {sort_key} //     from {table} c //    where {query_filter} //    union all //    ... //    order by {sort_key} //    limit n offset m) // select m.entity, to_jsonb(c.*) as data, c.id, c.{sort_key} //   from {table} c, matches m //  where c.vid = m.vid and m.entity = '...' //  union all //  ... //  order by c.{sort_key} // Step 1: build matches CTE out . push_sql ( " " ) ; for ( i , ( table , filter ) ) in entities . iter ( ) . enumerate ( ) { if i > 0 { out . push_sql ( " \n \n " ) ; } // select '..' as entity, //        c.id, //        c.vid, //        c.${sort_key} out . push_sql ( " " ) ; out . push_sql ( & table . object ) ; out . push_sql ( " " ) ; self . sort_key . select ( & mut out ) ? ; self . filtered_rows ( table , filter , out . reborrow ( ) ) ? ; } out . push_sql ( " \n " ) ; self . sort_key . order_by ( & mut out ) ? ; self . limit ( & mut out ) ; out . push_sql ( " \n " ) ; // Step 2: convert to JSONB for ( i , ( table , _ ) ) in entities . iter ( ) . enumerate ( ) { if i > 0 { out . push_sql ( " \n \n " ) ; } out . push_sql ( " " ) ; self . sort_key . select ( & mut out ) ? ; out . push_sql ( " \n " ) ; out . push_sql ( table . qualified_name . as_str ( ) ) ; out . push_sql ( " " ) ; out . push_sql ( " " ) ; out . push_sql ( " \n " ) ; out . push_bind_param :: < Text , _ > ( & table . object ) ? ; } out . push_sql ( " \n " ) ; self . sort_key . order_by ( & mut out ) ? ; Ok ( ( ) ) }
No windowing, but multiple entity types
No windowing but multiple entity types
&self
entities
&Vec<(&Table, Option<QueryFilter>)>
out
AstPass<Pg>
&self
entities
&Vec<(&Table, Option<QueryFilter>)>
out
AstPass<Pg>