Dynamic columns are columns that are added to a query only if they are visible.
The idea is that some queries might be expensive and we don't want to do them unless the data is being used.
Same thing for dynamic filters. The data for the filter does not need to be queried unless we are actually retricting the results on that filter. This eliminates a join in the query.
This came up when we were building a list where the columns could be the answers to questions from an assessment. To add a column for an assessment answer, we need to do a join for every question we are interested in. An assessment can have many questions but only a few might be interesting at any point, for the list.
The idea I had so far, is to add new attributes for elements and filters.
For elements I added a select_clause, from_clause, where clause (probably can do the join in the select clause also, I just thought of that).
For filters I added from_clause.
I also added a check so that is an element and filter have the same from clause or where clause, it is not duplicated.
I added some helper procedures to pull these out:
template::list::element_select_clauses
template::list::element_from_clauses
template::list::element_where_clauses
template::list::filter_from_clauses
and the appropriate variables to list_properties to make it work.
I am looking for feedback on this design, and and ideas people might have on how this could work.