-
-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Labels
enhancementNew feature or requestNew feature or request
Description
It is great that the *FragmentExpression.sql functions default to converting interpolated values in tagged templates to sql parameters. However, some cases are simplified by enabling direct interpolation.
I understand that this enables sql injection if injected value is not sanitized, but I think having the option is good similar to how most template engines sanitize HTML by default but provide a construct for raw injection if needed.
One common convention in many template based libraries (eg leafac/sqlite) is to use $${...} for raw sql interpolation.
This would enable usages like:
const duration = 10;
conn
.update(tJoinCode)
.set({ isActive: false })
.where(tJoinCode.deactivatedAt.lessThan(
conn
.fragmentWithType('localDateTime', 'required')
.sql`now() - interval '$${duration} minute'`)
))
So basically in this proposal the sql function will look at the last character before the interpolation and will use direct interpolation if its $.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request