View Source Electric.Replication.Eval.Lookups (electric v0.7.2)
Summary
Functions
Given multiple possible function overloads (same name and arity), try to find a concrete implementation that matches the argument types.
Given multiple possible operator overloads (same name and arity), try to find a concrete implementation that matches the argument types.
Functions
@spec pick_concrete_function_overload( list(), [struct()], Electric.Replication.Eval.Env.t() ) :: {:ok, term()} | :error
Given multiple possible function overloads (same name and arity), try to find a concrete implementation that matches the argument types.
Rules for picking a function overload closely mimic those outlined in postgres documentation:
- Check if there is an overload where all variable types match exactly
- Check if only one overload remains based on implicit conversion rules (unknowns are considered always matching), discard those that cannot be applied even after implicit conversion
- Check if only one overload remains based on most exact type matches
- Keep overloads that accept most preferred types in each conversion spot
- If there are any unknowns, for each position first look for any overloads that
accept
string
category, and if none found, check if all overloads accept the same type category. If that fails, keep all overloads, or pick any that don't accept picked category - If there are both unknown and known arguments, and all known arguments have the same type category, assume unknowns have the same type category and look for overloads that fit.
If exactly one overload matched after those steps, pick it, otherwise fail.
@spec pick_concrete_operator_overload( list(), [struct()], Electric.Replication.Eval.Env.t() ) :: {:ok, term()} | :error
Given multiple possible operator overloads (same name and arity), try to find a concrete implementation that matches the argument types.
Operators can only be 1 or 2-arity.
Rules for picking a operation overload closely mimic those outlined in postgres
documentation, and
mostly match pick_concrete_function_overload/3
.