Ecto v2.2.6 Ecto.Adapters.SQL.Connection behaviour View Source

Specifies the behaviour to be implemented by all SQL connections.

Link to this section Summary

Types

The cache query which is a DBConnection Query

The prepared query which is an SQL command

Callbacks

Receives a query and must return a SELECT query

Receives options and returns DBConnection supervisor child specification

Returns a DELETE for the filters returning the given returning

Receives a query and must return a DELETE query

Receives a DDL command and returns a query that executes it

Returns an INSERT for the given rows in table returning the given returning

Returns a stream that prepares and executes the given query with DBConnection

Receives the exception returned by query/4

Returns an UPDATE for the given fields in table filtered by filters returning the given returning

Receives a query and values to update and must return an UPDATE query

Link to this section Types

Link to this type cached() View Source
cached() :: map

The cache query which is a DBConnection Query

The prepared query which is an SQL command

Link to this section Callbacks

Link to this callback all(query) View Source
all(query :: Ecto.Query.t) :: iodata

Receives a query and must return a SELECT query.

Link to this callback child_spec(options) View Source
child_spec(options :: Keyword.t) :: {module, Keyword.t}

Receives options and returns DBConnection supervisor child specification.

Link to this callback delete(prefix, table, filters, returning) View Source
delete(prefix :: String.t, table :: String.t, filters :: [atom], returning :: [atom]) :: iodata

Returns a DELETE for the filters returning the given returning.

Link to this callback delete_all(query) View Source
delete_all(query :: Ecto.Query.t) :: iodata

Receives a query and must return a DELETE query.

Link to this callback execute(connection, prepared_query, params, options) View Source
execute(connection :: DBConnection.t, prepared_query :: cached, params :: [term], options :: Keyword.t) ::
  {:ok, term} |
  {:error | :reset, Exception.t}
execute(connection :: DBConnection.t, prepared_query :: prepared, params :: [term], options :: Keyword.t) ::
  {:ok, term} |
  {:error, Exception.t}
Link to this callback execute_ddl(command) View Source
execute_ddl(command :: Ecto.Adapter.Migration.command) ::
  String.t |
  [iodata]

Receives a DDL command and returns a query that executes it.

Link to this callback insert(prefix, table, header, rows, on_conflict, returning) View Source
insert(prefix :: String.t, table :: String.t, header :: [atom], rows :: [[atom | nil]], on_conflict :: Ecto.Adapter.on_conflict, returning :: [atom]) :: iodata

Returns an INSERT for the given rows in table returning the given returning.

Link to this callback prepare_execute(connection, name, prepared, params, options) View Source
prepare_execute(connection :: DBConnection.t, name :: String.t, prepared, params :: [term], options :: Keyword.t) ::
  {:ok, query :: map, term} |
  {:error, Exception.t}

Prepares and executes the given query with DBConnection.

Link to this callback stream(connection, prepared_query, params, options) View Source
stream(connection :: DBConnection.conn, prepared_query :: prepared, params :: [term], options :: Keyword.t) :: Enum.t

Returns a stream that prepares and executes the given query with DBConnection.

Link to this callback to_constraints(exception) View Source
to_constraints(exception :: Exception.t) :: Keyword.t

Receives the exception returned by query/4.

The constraints are in the keyword list and must return the constraint type, like :unique, and the constraint name as a string, for example:

[unique: "posts_title_index"]

Must return an empty list if the error does not come from any constraint.

Link to this callback update(prefix, table, fields, filters, returning) View Source
update(prefix :: String.t, table :: String.t, fields :: [atom], filters :: [atom], returning :: [atom]) :: iodata

Returns an UPDATE for the given fields in table filtered by filters returning the given returning.

Link to this callback update_all(query) View Source
update_all(query :: Ecto.Query.t) :: iodata

Receives a query and values to update and must return an UPDATE query.