Arcadic.Trigger (Arcadic v0.7.0)

Copy Markdown View Source

ArcadeDB triggers — tenant-blind CREATE TRIGGER / DROP TRIGGER DDL, parallel to Arcadic.Function/Arcadic.Geo.

A trigger fires a timing (:before / :after) × event (:create / :delete / :update / :read) action on a type, running a body in one of three action languages (:sql / :javascript / :java). Each of the three dimensions is an internal atom → token allowlist — an off-enum atom rejects value-free before any wire call, never echoing the caller value.

The type name is the only identifier injection surface (interpolated behind Arcadic.Identifier, closed by construction); the body is embedded as a "..." DDL literal and admitted only through the same reject-not-escape guard Arcadic.Function uses — the sole breakout byte ", the backslash, and control/line bytes reject value-free (:unencodable_body) before any wire call. ArcadeDB's "..." body literal has no escape, so a body needing one is a substrate limit, not a narrowing. DROP TRIGGER takes no IF EXISTS clause (probe-confirmed) — dropping a missing trigger is a server error.

Summary

Functions

Creates a trigger name on type, firing a timing × event action that runs execute.

Creates a trigger, raising on error.

Drops a trigger name (no IF EXISTS — a missing trigger is a server error). Value-free on a bad name.

Drops a trigger, raising on error.

Functions

create(conn, name, type, opts \\ [])

@spec create(Arcadic.Conn.t(), String.t(), String.t(), keyword()) ::
  :ok | {:error, atom() | Exception.t()}

Creates a trigger name on type, firing a timing × event action that runs execute.

opts (all required): :timing (:before | :after), :event (:create | :delete | :update | :read), :execute (a {lang, code} tuple — lang one of :sql | :javascript | :java, code a single-line body literal). Emits CREATE TRIGGER name TIMING EVENT ON type EXECUTE LANG "code".

Value-free on a bad identifier (:invalid_identifier), an off-enum timing / event / language (:invalid_timing / :invalid_event / :invalid_language), a malformed or missing :execute (:invalid_execute), or an unencodable body (:unencodable_body) — none echo the offending value. A non-binary body is a caller-contract violation and raises ArgumentError value-free.

create!(conn, name, type, opts \\ [])

@spec create!(Arcadic.Conn.t(), String.t(), String.t(), keyword()) :: :ok

Creates a trigger, raising on error.

drop(conn, name)

@spec drop(Arcadic.Conn.t(), String.t()) :: :ok | {:error, atom() | Exception.t()}

Drops a trigger name (no IF EXISTS — a missing trigger is a server error). Value-free on a bad name.

drop!(conn, name)

@spec drop!(Arcadic.Conn.t(), String.t()) :: :ok

Drops a trigger, raising on error.