# `Electric.Replication.Eval.Expr`
[🔗](https://github.com/electric-sql/electric/tree/%40core/sync-service%401.6.2/packages/sync-service/lib/electric/replication/eval/expr.ex#L1)

Parsed expression, available for evaluation using the runner

# `t`

```elixir
@type t() :: %Electric.Replication.Eval.Expr{
  eval: term(),
  query: String.t(),
  returns: Electric.Replication.Eval.Env.pg_type(),
  used_refs: used_refs()
}
```

# `used_refs`

```elixir
@type used_refs() :: %{
  required([String.t(), ...]) =&gt; Electric.Replication.Eval.Env.pg_type()
}
```

# `unqualified_refs`

```elixir
@spec unqualified_refs(t()) :: [String.t()]
```

Returns a flat list of all used refs used in the expression
that point to the current table

## Examples

    iex> used_refs = %{["id"] => :int8, ["created_at"] => :timestamp}
    iex> unqualified_refs(%Expr{query: "id = 1", used_refs: used_refs})
    ["created_at", "id"]

    iex> used_refs = %{["id"] => :int8, ["potato", "created_at"] => :timestamp}
    iex> unqualified_refs(%Expr{query: "id = 1", used_refs: used_refs, returns: :int8})
    ["id"]

# `wrap_parser_part`

Wrap a parser part (Const, Ref, Func, Array, RowExpr) in an Expr struct, so that it can be evaluated on it's own.

This is used when a subtree of our AST needs to be made evaluatable on it's own inside Electric. The `query` field
is not needed in that context, it's used when going back to postgres, so we don't bother calculating it.

---

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