Create interceptor for processing custom tagged template value expressions
gajus opened this issue · 2 comments
The way that Slonik is using tagged template literals to generate code fragments and safely bind parameter values is particularly exciting. Therefore, I am exploring feasibility of allowing community to bring their own code-generating extensions that integrate into Slonik template language. These extensions will allow to abstract business-specific fragments of code (e.g. dynamic WHERE conditions for a particular business requirement); big development teams can use this pattern to restrict any use of raw.sql
in the main codebase. This enables separating integration and code generation tests.
The primary considerations:
- Design of value expression that does not compromise the strict type nature of the current tags.
- Client configuration that restricts use of
sql.raw
tokens, but allows custom extensions.
This should also provide features equivalent to https://github.com/vitaly-t/pg-promise#custom-type-formatting.
Users can already create custom tags simply by using the already available query building utilities.