Shared SQL transformation utilities used by dialect implementations.
Dialect modules call these helpers from their transform_statement/1
callback to normalize SQL before variables are bound.
Summary
Functions
Strip single-quoted wrappers from simple variable placeholders.
Transform PostgreSQL INTERVAL syntax with variable placeholders.
Transform quoted wildcard patterns around variable placeholders into concatenation expressions using the given operator.
Functions
Strip single-quoted wrappers from simple variable placeholders.
Converts '{{email}}' → {{email}} but leaves complex expressions
like '%{{q}}%' unchanged (those are handled by wildcard transforms).
Transform PostgreSQL INTERVAL syntax with variable placeholders.
Handles patterns like:
INTERVAL {{var}}→({{var}}::text)::intervalINTERVAL '{{var}}'→CAST({{var}} AS interval)INTERVAL '{{n}} days'→make_interval(days => ({{n}})::integer)
Transform quoted wildcard patterns around variable placeholders into concatenation expressions using the given operator.
Operators
:pipe— uses||(Postgres, SQLite, default SQL):concat_fn— usesCONCAT()(MySQL)
Examples
transform_wildcards("'%{{q}}%'", :pipe)
# => "'%' || {{q}} || '%'"
transform_wildcards("'%{{q}}%'", :concat_fn)
# => "CONCAT('%', {{q}}, '%')"