Unlike other variable directives, they do not _*re...
# komapper
d
> Unlike other variable directives, they do not require test data immediately after the directive. In embedded variable directives docs, it sounds like it's possible to put test data there (which could be useful, like including test table names when using it for table names in FROM -- when keeping the sql runnable), but that doesn't really work...
t
Thank you for your feedback. It seems the documentation is incorrect. Embedded variable directives do not support test data. If we are to support something like embedded variable directives that handle test data, we should consider adding a new directive.
d
I'm not sure it's worth adding a new directive just for this... it would probably be more confusing... I guess maybe just the wording in docs could be fixed.
👍 1
t
When test data is needed for an embedded variable directive, it can currently be written as follows:
Copy code
select * from /*% if true *//*# tableName *//*% else */employee/*% end */
However, since this is verbose, we are considering making it possible to write it as follows:
Copy code
select * from /*% replace tableName */employee/*% end */
The above two SQL templates are transformed into the following SQL when the
tableName
variable is assigned `department`:
Copy code
select * from department
What do you think about this idea?
d
I think
replace
isn't really clear what's replacing what... also it's really an embedded directive with a sample value... is there any other advantage to it? If so, why change the syntax from other sample values that come right after the directive?