Selecto.DB.Adapter behaviour
(Selecto v0.4.5)
Copy Markdown
Behaviour contract for Selecto database adapters.
Adapter modules are responsible for:
- establishing a connection handle from adapter-specific options,
- executing SQL with bound params,
- providing adapter placeholder strategy,
- quoting identifiers when needed by adapter-specific tooling, and
- declaring coarse feature support.
Streaming contract:
supports?(:stream)should returntrueonly whenstream/4is implemented and can produce rows for the given connection context.stream/4is optional; adapters that do not support streaming should omit it and returnfalseforsupports?(:stream).
Summary
Types
@type connection() :: term()
@type execute_options() :: keyword()
@type introspection_options() :: keyword()
@type params() :: [term()]
@type schema_metadata() :: map()
@type server_version_result() :: {:ok, pos_integer()} | {:error, term()}
@type stream_result() :: {:ok, Enumerable.t()} | {:ok, Enumerable.t(), [String.t()]} | {:error, term()}
Callbacks
@callback connect(connection_options()) :: {:ok, connection()} | {:error, term()}
@callback connection_info(connection()) :: map()
@callback execute(connection(), query(), params(), execute_options()) :: {:ok, result()} | {:error, term()}
@callback execute_raw(connection(), query(), params()) :: {:ok, result()} | {:error, term()}
@callback introspect_table(connection(), String.t(), introspection_options()) :: {:ok, schema_metadata()} | {:error, term()}
@callback list_relations(connection(), introspection_options()) :: {:ok, [map()]} | {:error, term()}
@callback list_tables(connection(), introspection_options()) :: {:ok, [String.t()]} | {:error, term()}
@callback name() :: atom()
@callback placeholder(pos_integer()) :: iodata()
@callback refresh_materialized_view(connection(), String.t(), keyword()) :: {:ok, term()} | {:error, term()}
@callback rollup_literal_order(pos_integer()) :: iodata() | String.t()
@callback rollup_sort_fix(connection()) :: boolean()
@callback server_version_major(connection()) :: server_version_result()
@callback stream(connection(), query(), params(), execute_options()) :: stream_result()
@callback validate_connection(connection()) :: :ok | {:error, term()}