Skip to content

Commit 480526f

Browse files
format lib/**/*.ex
1 parent 2df2896 commit 480526f

7 files changed

Lines changed: 66 additions & 39 deletions

File tree

.formatter.exs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,5 @@ locals_without_parens = [
3030
locals_without_parens: locals_without_parens,
3131
export: [
3232
locals_without_parens: locals_without_parens
33-
],
34-
inputs: []
33+
]
3534
]

lib/ecto/adapters/myxql/connection.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ if Code.ensure_loaded?(MyXQL) do
897897
{:fragment, _, _} ->
898898
{nil, as_prefix ++ [?f | Integer.to_string(pos)], nil}
899899

900-
{:values, _, _} ->
900+
{:values, _, _} ->
901901
{nil, as_prefix ++ [?v | Integer.to_string(pos)], nil}
902902

903903
{table, schema, prefix} ->

lib/ecto/adapters/postgres/connection.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ if Code.ensure_loaded?(Postgrex) do
10631063

10641064
defp values_expr(types, idx) do
10651065
intersperse_reduce(types, ?,, idx, fn {_field, type}, idx ->
1066-
{[?$ , Integer.to_string(idx), ?:, ?: | tagged_to_db(type)], idx + 1}
1066+
{[?$, Integer.to_string(idx), ?:, ?: | tagged_to_db(type)], idx + 1}
10671067
end)
10681068
end
10691069

@@ -1131,7 +1131,7 @@ if Code.ensure_loaded?(Postgrex) do
11311131
{:fragment, _, _} ->
11321132
{nil, as_prefix ++ [?f | Integer.to_string(pos)], nil}
11331133

1134-
{:values, _, _} ->
1134+
{:values, _, _} ->
11351135
{nil, as_prefix ++ [?v | Integer.to_string(pos)], nil}
11361136

11371137
{table, schema, prefix} ->
@@ -1375,7 +1375,7 @@ if Code.ensure_loaded?(Postgrex) do
13751375

13761376
defp comments_for_columns(table_name, columns) do
13771377
Enum.flat_map(columns, fn
1378-
{:remove, _column_name, _column_type, _opts} ->
1378+
{:remove, _column_name, _column_type, _opts} ->
13791379
[]
13801380

13811381
{_operation, column_name, _column_type, opts} ->

lib/ecto/adapters/sql/application.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule Ecto.Adapters.SQL.Application do
55
def start(_type, _args) do
66
children = [
77
{DynamicSupervisor, strategy: :one_for_one, name: Ecto.MigratorSupervisor},
8-
{Task.Supervisor, name: Ecto.Adapters.SQL.StorageSupervisor},
8+
{Task.Supervisor, name: Ecto.Adapters.SQL.StorageSupervisor}
99
]
1010

1111
opts = [strategy: :one_for_one, name: Ecto.Adapters.SQL.Supervisor]

lib/ecto/adapters/sql/connection.ex

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ defmodule Ecto.Adapters.SQL.Connection do
44
"""
55

66
@typedoc "The query name"
7-
@type name :: String.t
7+
@type name :: String.t()
88

99
@typedoc "The SQL statement"
10-
@type statement :: String.t
10+
@type statement :: String.t()
1111

1212
@typedoc "The cached query which is a DBConnection Query"
1313
@type cached :: map
@@ -19,38 +19,38 @@ defmodule Ecto.Adapters.SQL.Connection do
1919
Receives options and returns `DBConnection` supervisor child
2020
specification.
2121
"""
22-
@callback child_spec(options :: Keyword.t) :: :supervisor.child_spec() | {module, Keyword.t}
22+
@callback child_spec(options :: Keyword.t()) :: :supervisor.child_spec() | {module, Keyword.t()}
2323

2424
@doc """
2525
Prepares and executes the given query with `DBConnection`.
2626
"""
27-
@callback prepare_execute(connection, name, statement, params, options :: Keyword.t) ::
28-
{:ok, cached, term} | {:error, Exception.t}
27+
@callback prepare_execute(connection, name, statement, params, options :: Keyword.t()) ::
28+
{:ok, cached, term} | {:error, Exception.t()}
2929

3030
@doc """
3131
Executes a cached query.
3232
"""
33-
@callback execute(connection, cached, params, options :: Keyword.t) ::
34-
{:ok, cached, term} | {:ok, term} | {:error | :reset, Exception.t}
33+
@callback execute(connection, cached, params, options :: Keyword.t()) ::
34+
{:ok, cached, term} | {:ok, term} | {:error | :reset, Exception.t()}
3535

3636
@doc """
3737
Runs the given statement as a query.
3838
"""
39-
@callback query(connection, statement, params, options :: Keyword.t) ::
40-
{:ok, term} | {:error, Exception.t}
39+
@callback query(connection, statement, params, options :: Keyword.t()) ::
40+
{:ok, term} | {:error, Exception.t()}
4141

4242
@doc """
4343
Runs the given statement as a multi-result query.
4444
"""
45-
@callback query_many(connection, statement, params, options :: Keyword.t) ::
46-
{:ok, term} | {:error, Exception.t}
45+
@callback query_many(connection, statement, params, options :: Keyword.t()) ::
46+
{:ok, term} | {:error, Exception.t()}
4747

4848
@doc """
4949
Returns a stream that prepares and executes the given query with
5050
`DBConnection`.
5151
"""
52-
@callback stream(connection, statement, params, options :: Keyword.t) ::
53-
Enum.t
52+
@callback stream(connection, statement, params, options :: Keyword.t()) ::
53+
Enum.t()
5454

5555
@doc """
5656
Receives the exception returned by `c:query/4`.
@@ -64,46 +64,60 @@ defmodule Ecto.Adapters.SQL.Connection do
6464
Must return an empty list if the error does not come
6565
from any constraint.
6666
"""
67-
@callback to_constraints(exception :: Exception.t, options :: Keyword.t) :: Keyword.t
67+
@callback to_constraints(exception :: Exception.t(), options :: Keyword.t()) :: Keyword.t()
6868

6969
## Queries
7070

7171
@doc """
7272
Receives a query and must return a SELECT query.
7373
"""
74-
@callback all(query :: Ecto.Query.t) :: iodata
74+
@callback all(query :: Ecto.Query.t()) :: iodata
7575

7676
@doc """
7777
Receives a query and values to update and must return an UPDATE query.
7878
"""
79-
@callback update_all(query :: Ecto.Query.t) :: iodata
79+
@callback update_all(query :: Ecto.Query.t()) :: iodata
8080

8181
@doc """
8282
Receives a query and must return a DELETE query.
8383
"""
84-
@callback delete_all(query :: Ecto.Query.t) :: iodata
84+
@callback delete_all(query :: Ecto.Query.t()) :: iodata
8585

8686
@doc """
8787
Returns an INSERT for the given `rows` in `table` returning
8888
the given `returning`.
8989
"""
90-
@callback insert(prefix ::String.t, table :: String.t,
91-
header :: [atom], rows :: [[atom | nil]],
92-
on_conflict :: Ecto.Adapter.Schema.on_conflict, returning :: [atom],
93-
placeholders :: [term]) :: iodata
90+
@callback insert(
91+
prefix :: String.t(),
92+
table :: String.t(),
93+
header :: [atom],
94+
rows :: [[atom | nil]],
95+
on_conflict :: Ecto.Adapter.Schema.on_conflict(),
96+
returning :: [atom],
97+
placeholders :: [term]
98+
) :: iodata
9499

95100
@doc """
96101
Returns an UPDATE for the given `fields` in `table` filtered by
97102
`filters` returning the given `returning`.
98103
"""
99-
@callback update(prefix :: String.t, table :: String.t, fields :: [atom],
100-
filters :: [atom], returning :: [atom]) :: iodata
104+
@callback update(
105+
prefix :: String.t(),
106+
table :: String.t(),
107+
fields :: [atom],
108+
filters :: [atom],
109+
returning :: [atom]
110+
) :: iodata
101111

102112
@doc """
103113
Returns a DELETE for the `filters` returning the given `returning`.
104114
"""
105-
@callback delete(prefix :: String.t, table :: String.t,
106-
filters :: [atom], returning :: [atom]) :: iodata
115+
@callback delete(
116+
prefix :: String.t(),
117+
table :: String.t(),
118+
filters :: [atom],
119+
returning :: [atom]
120+
) :: iodata
107121

108122
@doc """
109123
Executes an EXPLAIN query or similar depending on the adapter to obtains statistics of the given query.
@@ -113,23 +127,28 @@ defmodule Ecto.Adapters.SQL.Connection do
113127
114128
Must execute the explain query and return the result.
115129
"""
116-
@callback explain_query(connection, query :: String.t, params :: Keyword.t, opts :: Keyword.t) ::
117-
{:ok, term} | {:error, Exception.t}
130+
@callback explain_query(
131+
connection,
132+
query :: String.t(),
133+
params :: Keyword.t(),
134+
opts :: Keyword.t()
135+
) ::
136+
{:ok, term} | {:error, Exception.t()}
118137

119138
## DDL
120139

121140
@doc """
122141
Receives a DDL command and returns a query that executes it.
123142
"""
124-
@callback execute_ddl(command :: Ecto.Adapter.Migration.command) :: String.t | [iodata]
143+
@callback execute_ddl(command :: Ecto.Adapter.Migration.command()) :: String.t() | [iodata]
125144

126145
@doc """
127146
Receives a query result and returns a list of logs.
128147
"""
129-
@callback ddl_logs(result :: term) :: [{Logger.level, Logger.message, Logger.metadata}]
148+
@callback ddl_logs(result :: term) :: [{Logger.level(), Logger.message(), Logger.metadata()}]
130149

131150
@doc """
132151
Returns a queryable to check if the given `table` exists.
133152
"""
134-
@callback table_exists_query(table :: String.t) :: {iodata, [term]}
153+
@callback table_exists_query(table :: String.t()) :: {iodata, [term]}
135154
end

lib/ecto/adapters/sql/sandbox.ex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,31 +335,40 @@ defmodule Ecto.Adapters.SQL.Sandbox do
335335
case conn_mod.handle_begin(opts, state) do
336336
{:ok, value, state} ->
337337
{:ok, value, {conn_mod, state, true}}
338+
338339
{kind, err, state} ->
339340
{kind, err, {conn_mod, state, false}}
340341
end
341342
end
343+
342344
def handle_commit(opts, {conn_mod, state, true}) do
343345
opts = [mode: :savepoint] ++ opts
344346
proxy(:handle_commit, {conn_mod, state, false}, [opts])
345347
end
348+
346349
def handle_rollback(opts, {conn_mod, state, _}) do
347350
opts = [mode: :savepoint] ++ opts
348351
proxy(:handle_rollback, {conn_mod, state, false}, [opts])
349352
end
350353

351354
def handle_status(opts, state),
352355
do: proxy(:handle_status, state, [maybe_savepoint(opts, state)])
356+
353357
def handle_prepare(query, opts, state),
354358
do: proxy(:handle_prepare, state, [query, maybe_savepoint(opts, state)])
359+
355360
def handle_execute(query, params, opts, state),
356361
do: proxy(:handle_execute, state, [query, params, maybe_savepoint(opts, state)])
362+
357363
def handle_close(query, opts, state),
358364
do: proxy(:handle_close, state, [query, maybe_savepoint(opts, state)])
365+
359366
def handle_declare(query, params, opts, state),
360367
do: proxy(:handle_declare, state, [query, params, maybe_savepoint(opts, state)])
368+
361369
def handle_fetch(query, cursor, opts, state),
362370
do: proxy(:handle_fetch, state, [query, cursor, maybe_savepoint(opts, state)])
371+
363372
def handle_deallocate(query, cursor, opts, state),
364373
do: proxy(:handle_deallocate, state, [query, cursor, maybe_savepoint(opts, state)])
365374

lib/ecto/adapters/tds/connection.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ if Code.ensure_loaded?(Tds) do
964964

965965
defp values_expr(types, idx) do
966966
intersperse_reduce(types, ?,, idx, fn {_field, type}, idx ->
967-
{["CAST(", ?@ , Integer.to_string(idx), " AS ", column_type(type, []), ?)], idx + 1}
967+
{["CAST(", ?@, Integer.to_string(idx), " AS ", column_type(type, []), ?)], idx + 1}
968968
end)
969969
end
970970

@@ -1031,7 +1031,7 @@ if Code.ensure_loaded?(Tds) do
10311031
{:fragment, _, _} ->
10321032
{nil, as_prefix ++ [?f | Integer.to_string(pos)], nil}
10331033

1034-
{:values, _, _} ->
1034+
{:values, _, _} ->
10351035
{nil, as_prefix ++ [?v | Integer.to_string(pos)], nil}
10361036

10371037
{table, model, prefix} ->

0 commit comments

Comments
 (0)