In one sense, sql.template is poorly designed. It requires both an argument to sql_render, i.e. tags = ... to determine what to uncomment as well as data.

Probably a better way to do it is that if there is a value in data, that line is uncommented. For example:

SELECT 
  {{}}

Order of operations

Current: Uncomment, substitute, strip ... Proposed: substitute + uncomment ... strip (if remaining)

Functions

Uncommenting, activate conditions by

Parameterized comments are uncommented if the value is evaluated.
Do the values in whisker

Parameters:

/*{{filter_a}}: AND a = {{a}} */
--{{filter_b}}: AND b = {{b}}

Using a parameter to

--{{r}}: AND r = {{r}}

Order:

Currently, SQL is uncommented then

--actually, it simply has to evaluate to any value.

list( filter_a=TRUE, filter_b=FALSE )



This is equivalent to the code fence in RMarkdown

Most desirable

This is a dplyr type interface:

"Select * from table" %>% filter( name = "Fred" )



decisionpatterns/sql.template documentation built on July 6, 2020, 8:41 a.m.