|
@@ -41,7 +41,8 @@
|
|
|
|
|
|
-export_type([connection/0, connect_option/0, connect_opts/0,
|
|
|
connect_error/0, query_error/0, sql_query/0, column/0,
|
|
|
- type_name/0, epgsql_type/0, statement/0]).
|
|
|
+ type_name/0, epgsql_type/0, statement/0,
|
|
|
+ transaction_option/0, transaction_opts/0]).
|
|
|
|
|
|
%% Deprecated types
|
|
|
-export_type([bind_param/0, typed_param/0,
|
|
@@ -94,6 +95,19 @@
|
|
|
application_name => string()
|
|
|
}.
|
|
|
|
|
|
+-type transaction_option() ::
|
|
|
+ {reraise, boolean()} |
|
|
|
+ {ensure_committed, boolean()} |
|
|
|
+ {begin_opts, iodata()}.
|
|
|
+
|
|
|
+
|
|
|
+-type transaction_opts() ::
|
|
|
+ [transaction_option()]
|
|
|
+ | #{reraise => boolean(),
|
|
|
+ ensure_committed => boolean(),
|
|
|
+ begin_opts => iodata()
|
|
|
+ }.
|
|
|
+
|
|
|
-type connect_error() :: epgsql_cmd_connect:connect_error().
|
|
|
-type query_error() :: #error{}. % Error report generated by server
|
|
|
|
|
@@ -417,11 +431,8 @@ with_transaction(C, F) ->
|
|
|
%% Beware of SQL injections! No escaping is made on begin_opts! Default: `""'</dd>
|
|
|
%% </dl>
|
|
|
-spec with_transaction(
|
|
|
- connection(), fun((connection()) -> Reply), Opts) -> Reply | {rollback, any()} | no_return() when
|
|
|
- Reply :: any(),
|
|
|
- Opts :: [{reraise, boolean()} |
|
|
|
- {ensure_committed, boolean()} |
|
|
|
- {begin_opts, iodata()}].
|
|
|
+ connection(), fun((connection()) -> Reply), transaction_opts()) -> Reply | {rollback, any()} | no_return() when
|
|
|
+ Reply :: any().
|
|
|
with_transaction(C, F, Opts0) ->
|
|
|
Opts = to_map(Opts0),
|
|
|
Begin = case Opts of
|