Ecto v1.1.0 Ecto.Adapters.SQL.Query behaviour
Specifies the behaviour to be implemented by the connection for handling all SQL queries.
Summary
Callbacks
Receives a query and must return a SELECT query
Command to begin transaction
Command to commit transaction
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 fields
in table
returning
the given returning
Executes the given query with params in connection
Command to rollback transaction
Command to rollback to savepoint
Command to emit savepoint
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
Types
result ::
{:ok, %{rows: nil | [tuple], num_rows: non_neg_integer}} |
{:error, Exception.t}
Callbacks
Specs
Returns a DELETE for the filters
returning the given returning
.
Specs
delete_all(Ecto.Query.t) :: String.t
Receives a query and must return a DELETE query.
Specs
execute_ddl(Ecto.Adapter.Migration.command) :: String.t
Receives a DDL command and returns a query that executes it.
Specs
Returns an INSERT for the given fields
in table
returning
the given returning
.
Executes the given query with params in connection.
In case of success, it must return an :ok
tuple containing
a map with at least two keys:
:num_rows
- the number of rows affected:rows
- the result set as a list.nil
may be returned instead of the list if the command does not yield any row as result (but still yields the number of affected rows, like adelete
command without returning would)
Command to rollback to savepoint.
Specs
to_constraints(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.
Specs
Returns an UPDATE for the given fields
in table
filtered by
filters
returning the given returning
.
Specs
update_all(Ecto.Query.t) :: String.t
Receives a query and values to update and must return an UPDATE query.