Electric.Replication.Eval.Expr (electric v1.4.11)
View SourceParsed 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
Wrap a parser part (Const, Ref, Func, Array, RowExpr) in an Expr struct, so that it can be evaluated on it's own.
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
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 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.