Ecto.Adapters.SQL.Connection behaviour

Source

Callbacks

all/1

Specs:

Receives a query and must return a SELECT query.

Source
begin_transaction/0

Specs:

Command to begin transaction.

Source
commit/0

Specs:

Command to commit transaction.

Source
connect/1

Specs:

  • connect(Keyword.t) :: {:ok, pid} | {:error, term}

Connects to the underlying database.

Should return a process which is linked to the caller process or an error.

Source
ddl_exists/1

Specs:

Receives a DDL object and returns a query that checks its existence.

Source
delete/3

Specs:

Returns a DELETE for the filters returning the given returning.

Source
delete_all/1

Specs:

Receives a query and must return a DELETE query.

Source
disconnect/1

Specs:

  • disconnect(pid) :: :ok

Disconnects the given pid.

If the given pid no longer exists, it should not raise.

Source
execute_ddl/1

Specs:

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

Source
insert/3

Specs:

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

Source
query/4

Specs:

  • query(pid, query :: binary, params :: list, opts :: Keyword.t) :: {:ok, %{rows: nil | [tuple], num_rows: non_neg_integer}} | {:error, Exception.t}

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 a delete command without returning would)

Source
rollback/0

Specs:

Command to rollback transaction.

Source
rollback_to_savepoint/1

Specs:

Command to rollback to savepoint.

Source
savepoint/1

Specs:

Command to emit savepoint.

Source
update/4

Specs:

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

Source
update_all/2

Specs:

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

Source