View Source Electric.Replication.Eval.Expr (electric v1.0.1)

Parsed expression, available for evaluation using the runner

Summary

Functions

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

Types

@type t() :: %Electric.Replication.Eval.Expr{
  eval: term(),
  query: String.t(),
  returns: Electric.Replication.Eval.Env.pg_type(),
  used_refs: used_refs()
}
@type used_refs() :: %{
  required([String.t(), ...]) => Electric.Replication.Eval.Env.pg_type()
}

Functions

@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"]