# `Lotus.SQL.Transformer`
[🔗](https://github.com/elixir-lotus/lotus/blob/v1.3.0/lib/lotus/sql/transformer.ex#L1)

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.

Every transform tokenizes with `Lotus.Query.Tokenizer` under the dialect's
`Lotus.Query.Tokenizer.Profile` and only rewrites string literals and code,
so a pattern inside a comment, a quoted identifier or a dollar-quoted body
is left alone. The profile defaults to ANSI SQL.

# `strip_quoted_variables`

```elixir
@spec strip_quoted_variables(String.t(), Lotus.Query.Tokenizer.Profile.t()) ::
  String.t()
```

Strip quote wrappers from simple variable placeholders.

Converts `'{{email}}'` → `{{email}}` but leaves complex expressions
like `'%{{q}}%'` unchanged (those are handled by wildcard transforms).
Any string quote of the profile counts, so MySQL's `"{{email}}"` is
unwrapped too, while a double-quoted identifier on Postgres is not.

# `transform_pg_intervals`

```elixir
@spec transform_pg_intervals(String.t(), Lotus.Query.Tokenizer.Profile.t()) ::
  String.t()
```

Transform PostgreSQL INTERVAL syntax with variable placeholders.

Handles patterns like:
  * `INTERVAL {{var}}` → `({{var}}::text)::interval`
  * `INTERVAL '{{var}}'` → `CAST({{var}} AS interval)`
  * `INTERVAL '{{n}} days'` → `make_interval(days => ({{n}})::integer)`

The keyword is matched without regard to case.

# `transform_wildcards`

```elixir
@spec transform_wildcards(
  String.t(),
  :pipe | :concat_fn,
  Lotus.Query.Tokenizer.Profile.t()
) ::
  String.t()
```

Transform quoted wildcard patterns around variable placeholders into
concatenation expressions using the given operator.

## Operators

  * `:pipe` — uses `||` (Postgres, SQLite, default SQL)
  * `:concat_fn` — uses `CONCAT()` (MySQL)

## Examples

    transform_wildcards("'%{{q}}%'", :pipe)
    # => "'%' || {{q}} || '%'"

    transform_wildcards("'%{{q}}%'", :concat_fn)
    # => "CONCAT('%', {{q}}, '%')"

---

*Consult [api-reference.md](api-reference.md) for complete listing*
