Ecto SQL v3.1.1 Ecto.Adapters.SQL.Connection behaviour View Source
Specifies the behaviour to be implemented by all SQL connections.
Link to this section Summary
Callbacks
Receives a query and must return a SELECT query.
Receives options and returns DBConnection
supervisor child
specification.
Receives a query result and returns a list of logs.
Returns a DELETE for the filters
returning the given returning
.
Receives a query and must return a DELETE query.
Executes a cached 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
.
Prepares and executes the given query with DBConnection
.
Runs the given statement as query.
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
cached()
View Source
cached() :: map()
cached() :: map()
The cached query which is a DBConnection Query
connection()
View Source
connection() :: DBConnection.conn()
connection() :: DBConnection.conn()
name()
View Source
name() :: String.t()
name() :: String.t()
The query name
params()
View Source
params() :: [term()]
params() :: [term()]
statement()
View Source
statement() :: String.t()
statement() :: String.t()
The SQL statement
Link to this section Callbacks
all(query)
View Source
all(query :: Ecto.Query.t()) :: iodata()
all(query :: Ecto.Query.t()) :: iodata()
Receives a query and must return a SELECT query.
child_spec(options) View Source
Receives options and returns DBConnection
supervisor child
specification.
ddl_logs(result)
View Source
ddl_logs(result :: term()) :: [
{Logger.level(), Logger.message(), Logger.metadata()}
]
ddl_logs(result :: term()) :: [ {Logger.level(), Logger.message(), Logger.metadata()} ]
Receives a query result and returns a list of logs.
delete(prefix, table, filters, returning) View Source
Returns a DELETE for the filters
returning the given returning
.
delete_all(query)
View Source
delete_all(query :: Ecto.Query.t()) :: iodata()
delete_all(query :: Ecto.Query.t()) :: iodata()
Receives a query and must return a DELETE query.
execute(connection, cached, params, options)
View Source
execute(connection(), cached(), params(), options :: Keyword.t()) ::
{:ok, cached(), term()} | {:ok, term()} | {:error | :reset, Exception.t()}
execute(connection(), cached(), params(), options :: Keyword.t()) :: {:ok, cached(), term()} | {:ok, term()} | {:error | :reset, Exception.t()}
Executes a cached query.
execute_ddl(command)
View Source
execute_ddl(command :: Ecto.Adapter.Migration.command()) ::
String.t() | [iodata()]
execute_ddl(command :: Ecto.Adapter.Migration.command()) :: String.t() | [iodata()]
Receives a DDL command and returns a query that executes it.
insert(prefix, table, header, rows, on_conflict, returning) View Source
Returns an INSERT for the given rows
in table
returning
the given returning
.
prepare_execute(connection, name, statement, params, options)
View Source
prepare_execute(
connection(),
name(),
statement(),
params(),
options :: Keyword.t()
) :: {:ok, cached(), term()} | {:error, Exception.t()}
prepare_execute( connection(), name(), statement(), params(), options :: Keyword.t() ) :: {:ok, cached(), term()} | {:error, Exception.t()}
Prepares and executes the given query with DBConnection
.
query(connection, statement, params, options)
View Source
query(connection(), statement(), params(), options :: Keyword.t()) ::
{:ok, term()} | {:error, Exception.t()}
query(connection(), statement(), params(), options :: Keyword.t()) :: {:ok, term()} | {:error, Exception.t()}
Runs the given statement as query.
stream(connection, statement, params, options)
View Source
stream(connection(), statement(), params(), options :: Keyword.t()) :: Enum.t()
stream(connection(), statement(), params(), options :: Keyword.t()) :: Enum.t()
Returns a stream that prepares and executes the given query with
DBConnection
.
to_constraints(exception)
View Source
to_constraints(exception :: Exception.t()) :: Keyword.t()
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.
update(prefix, table, fields, filters, returning) View Source
Returns an UPDATE for the given fields
in table
filtered by
filters
returning the given returning
.
update_all(query)
View Source
update_all(query :: Ecto.Query.t()) :: iodata()
update_all(query :: Ecto.Query.t()) :: iodata()
Receives a query and values to update and must return an UPDATE query.