Skip to content

Commit a3569e2

Browse files
authored
update CI, format (#16)
1 parent e5e8230 commit a3569e2

File tree

10 files changed

+139
-75
lines changed

10 files changed

+139
-75
lines changed

.formatter.exs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Used by "mix format"
22
[
3-
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
3+
inputs: [
4+
"{mix,.formatter}.exs",
5+
"{lib,test}/**/*.{ex,exs}"
6+
],
47
line_length: 88
58
]

.github/workflows/ci.yml

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,50 @@
11
name: CI
2-
on: [push, pull_request]
3-
jobs:
4-
test-elixir:
5-
runs-on: ubuntu-latest
6-
container: elixir:${{ matrix.elixir_version }}-slim
72

3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-20.04
12+
env:
13+
MIX_ENV: test
814
strategy:
15+
fail-fast: false
916
matrix:
10-
elixir_version: ["1.8", "1.9", "1.10", "1.11"]
11-
17+
include:
18+
- pair:
19+
elixir: 1.8.2
20+
otp: 20.3.8.26
21+
- pair:
22+
elixir: 1.11.4
23+
otp: 23.2.7
24+
lint: lint
1225
steps:
1326
- uses: actions/checkout@v2
1427

15-
- name: Install system dependencies
16-
run: |
17-
apt-get update
18-
apt-get install --no-install-recommends -y git build-essential
19-
mix local.rebar --force
20-
mix local.hex --force
21-
mix deps.get
28+
- uses: erlef/setup-elixir@v1
29+
with:
30+
otp-version: ${{matrix.pair.otp}}
31+
elixir-version: ${{matrix.pair.elixir}}
32+
33+
- name: Install Dependencies
34+
run: mix deps.get --only test
35+
36+
- run: mix format --check-formatted
37+
if: ${{ matrix.lint }}
38+
39+
- run: mix deps.get && mix deps.unlock --check-unused
40+
if: ${{ matrix.lint }}
41+
42+
- run: mix deps.compile
43+
44+
# test/support throwing compile errors, but will soon be refactored
45+
# - run: mix compile --warnings-as-errors
46+
# if: ${{ matrix.lint }}
47+
48+
- run: mix test
2249

23-
- run: mix test --trace
24-
- run: EXQLITE_INTEGRATION=true mix test --trace
50+
- run: EXQLITE_INTEGRATION=true mix test

lib/ecto/adapters/sqlite3/codec.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ defmodule Ecto.Adapters.SQLite3.Codec do
8888
def decimal_encode(%Decimal{} = x) do
8989
{:ok, Decimal.to_string(x, :normal)}
9090
end
91+
9192
# def decimal_encode(x), do: {:ok, x}
9293

9394
def time_encode(value) do

lib/ecto/adapters/sqlite3/connection.ex

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ defmodule Ecto.Adapters.SQLite3.Connection do
146146
end
147147

148148
@impl true
149-
def to_constraints(%Exqlite.Error{message: "UNIQUE constraint failed: " <> constraint}, _opts) do
149+
def to_constraints(
150+
%Exqlite.Error{message: "UNIQUE constraint failed: " <> constraint},
151+
_opts
152+
) do
150153
[unique: constraint_name_hack(constraint)]
151154
end
152155

@@ -267,6 +270,7 @@ defmodule Ecto.Adapters.SQLite3.Connection do
267270
returning(returning)
268271
]
269272
end
273+
270274
def insert(prefix, table, header, rows, on_conflict, returning, _placeholders) do
271275
fields = quote_names(header)
272276

@@ -680,7 +684,11 @@ defmodule Ecto.Adapters.SQLite3.Connection do
680684
end
681685

682686
defp on_conflict({query, _, targets}, _header) do
683-
[" ON CONFLICT ", conflict_target(targets), "DO " | update_all(query, "UPDATE SET ")]
687+
[
688+
" ON CONFLICT ",
689+
conflict_target(targets),
690+
"DO " | update_all(query, "UPDATE SET ")
691+
]
684692
end
685693

686694
defp conflict_target([]), do: ""
@@ -691,11 +699,11 @@ defmodule Ecto.Adapters.SQLite3.Connection do
691699

692700
defp replace(fields) do
693701
[
694-
"UPDATE SET " |
695-
intersperse_map(fields, ?,, fn field ->
696-
quoted = quote_name(field)
697-
[quoted, " = ", "EXCLUDED." | quoted]
698-
end)
702+
"UPDATE SET "
703+
| intersperse_map(fields, ?,, fn field ->
704+
quoted = quote_name(field)
705+
[quoted, " = ", "EXCLUDED." | quoted]
706+
end)
699707
]
700708
end
701709

@@ -739,6 +747,7 @@ defmodule Ecto.Adapters.SQLite3.Connection do
739747
{_expr, name, _schema} = create_name(sources, 0, [])
740748
[" AS " | name]
741749
end
750+
742751
defp insert_as({_, _, _}) do
743752
[]
744753
end
@@ -779,7 +788,10 @@ defmodule Ecto.Adapters.SQLite3.Connection do
779788
end
780789

781790
def select(%{select: %{fields: fields}, distinct: distinct} = query, sources) do
782-
["SELECT ", distinct(distinct, sources, query) | select_fields(fields, sources, query)]
791+
[
792+
"SELECT ",
793+
distinct(distinct, sources, query) | select_fields(fields, sources, query)
794+
]
783795
end
784796

785797
defp select_fields([], _sources, _query), do: "1"
@@ -1157,7 +1169,13 @@ defmodule Ecto.Adapters.SQLite3.Connection do
11571169
end
11581170

11591171
def expr({:in, _, [left, right]}, sources, query) do
1160-
[expr(left, sources, query), " IN (SELECT value FROM JSON_EACH(", expr(right, sources, query), ?), ?)]
1172+
[
1173+
expr(left, sources, query),
1174+
" IN (SELECT value FROM JSON_EACH(",
1175+
expr(right, sources, query),
1176+
?),
1177+
?)
1178+
]
11611179
end
11621180

11631181
def expr({:is_nil, _, [arg]}, sources, query) do
@@ -1585,6 +1603,7 @@ defmodule Ecto.Adapters.SQLite3.Connection do
15851603
defp reference_on_update(_), do: []
15861604

15871605
defp returning(%{select: nil}, _sources), do: []
1606+
15881607
defp returning(%{select: %{fields: fields}} = query, sources) do
15891608
[
15901609
" RETURNING " | select_fields(fields, sources, query)
@@ -1625,7 +1644,8 @@ defmodule Ecto.Adapters.SQLite3.Connection do
16251644
end
16261645

16271646
defp composite_fk_definitions(%Table{} = table, columns) do
1628-
composite_fk_cols = columns
1647+
composite_fk_cols =
1648+
columns
16291649
|> Enum.filter(fn c ->
16301650
case c do
16311651
{_op, _name, %Reference{with: [_]}, _opts} -> true
@@ -1650,7 +1670,6 @@ defmodule Ecto.Adapters.SQLite3.Connection do
16501670
reference_on_delete(ref.on_delete),
16511671
reference_on_update(ref.on_update)
16521672
]
1653-
16541673
end
16551674

16561675
defp get_source(query, sources, ix, source) do

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ defmodule EctoSQLite3.MixProject do
7171

7272
defp docs do
7373
[
74-
main: "Ecto.Adapters.SQLite3",
74+
main: "Ecto.Adapters.SQLite3"
7575
]
7676
end
7777

mix.lock

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
"benchee_json": {:hex, :benchee_json, "0.4.0", "59d3277829bd1dca8373cdb20b916cb435c2647be235d09963fc0959db908c36", [:mix], [{:benchee, "~> 0.10", [hex: :benchee, repo: "hexpm", optional: false]}, {:poison, ">= 1.4.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm", "71a3edb6a30708de2a01368aa8f288e1c0ed7897b125adc396ce7c2c7245b1e7"},
44
"connection": {:hex, :connection, "1.1.0", "ff2a49c4b75b6fb3e674bfc5536451607270aac754ffd1bdfe175abe4a6d7a68", [:mix], [], "hexpm", "722c1eb0a418fbe91ba7bd59a47e28008a189d47e37e0e7bb85585a016b2869c"},
55
"db_connection": {:hex, :db_connection, "2.3.1", "4c9f3ed1ef37471cbdd2762d6655be11e38193904d9c5c1c9389f1b891a3088e", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm", "abaab61780dde30301d840417890bd9f74131041afd02174cf4e10635b3a63f5"},
6-
"decimal": {:hex, :decimal, "1.9.0", "83e8daf59631d632b171faabafb4a9f4242c514b0a06ba3df493951c08f64d07", [:mix], [], "hexpm", "b1f2343568eed6928f3e751cf2dffde95bfaa19dd95d09e8a9ea92ccfd6f7d85"},
6+
"decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"},
77
"deep_merge": {:hex, :deep_merge, "0.2.0", "c1050fa2edf4848b9f556fba1b75afc66608a4219659e3311d9c9427b5b680b3", [:mix], [], "hexpm", "e3bf435a54ed27b0ba3a01eb117ae017988804e136edcbe8a6a14c310daa966e"},
88
"earmark_parser": {:hex, :earmark_parser, "1.4.12", "b245e875ec0a311a342320da0551da407d9d2b65d98f7a9597ae078615af3449", [:mix], [], "hexpm", "711e2cc4d64abb7d566d43f54b78f7dc129308a63bc103fbd88550d2174b3160"},
99
"ecto": {:hex, :ecto, "3.5.8", "8ebf12be6016cb99313348ba7bb4612f4114b9a506d6da79a2adc7ef449340bc", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ea0be182ea8922eb7742e3ae8e71b67ee00ae177de1bf76210299a5f16ba4c77"},
1010
"ecto_sql": {:hex, :ecto_sql, "3.5.4", "a9e292c40bd79fff88885f95f1ecd7b2516e09aa99c7dd0201aa84c54d2358e4", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.5.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.3.0 or ~> 0.4.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "1fff1a28a898d7bbef263f1f3ea425b04ba9f33816d843238c84eff883347343"},
1111
"elixir_make": {:hex, :elixir_make, "0.6.2", "7dffacd77dec4c37b39af867cedaabb0b59f6a871f89722c25b28fcd4bd70530", [:mix], [], "hexpm", "03e49eadda22526a7e5279d53321d1cced6552f344ba4e03e619063de75348d9"},
12-
"esqlite": {:hex, :esqlite, "0.4.1", "ba5d0bab6b9c8432ffe1bf12fee8e154a50f1c3c40eadc3a9c870c23ca94d961", [:rebar3], [], "hexpm", "3584ca33172f4815ce56e96eed9835f5d8c987a9000fbc8c376c86acef8bf965"},
1312
"ex_doc": {:hex, :ex_doc, "0.23.0", "a069bc9b0bf8efe323ecde8c0d62afc13d308b1fa3d228b65bca5cf8703a529d", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "f5e2c4702468b2fd11b10d39416ddadd2fcdd173ba2a0285ebd92c39827a5a16"},
14-
"exqlite": {:hex, :exqlite, "0.5.0", "1c48c817ef4ea802c45b069e139a34cf2d85d9188ab3a99c6d6eea3d4903dfa3", [:make, :mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "fab56c6bdebcfb1a238c5b501df86d74083d75af70ae0fde595a535f0ab45811"},
13+
"exqlite": {:hex, :exqlite, "0.5.1", "fae7e66718fd33318904e826a42769e0ddbe7afc41dfcbff3332cbf3e728daa4", [:make, :mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "e04a66c3a51e3e9d1f00189c90591c4902ae32de557b98089d1846e69e44df67"},
1514
"jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"},
1615
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
1716
"makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"},

test/ecto/adapters/sqlite3/connection_test.exs

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,14 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
386386

387387
test "aggregate filters" do
388388
query = Schema |> select([r], count(r.x) |> filter(r.x > 10)) |> plan()
389-
assert all(query) == ~s{SELECT count(s0.x) FILTER (WHERE s0.x > 10) FROM schema AS s0}
389+
390+
assert all(query) ==
391+
~s{SELECT count(s0.x) FILTER (WHERE s0.x > 10) FROM schema AS s0}
390392

391393
query = Schema |> select([r], count(r.x) |> filter(r.x > 10 and r.x < 50)) |> plan()
392-
assert all(query) == ~s{SELECT count(s0.x) FILTER (WHERE (s0.x > 10) AND (s0.x < 50)) FROM schema AS s0}
394+
395+
assert all(query) ==
396+
~s{SELECT count(s0.x) FILTER (WHERE (s0.x > 10) AND (s0.x < 50)) FROM schema AS s0}
393397

394398
query = Schema |> select([r], count() |> filter(r.x > 10)) |> plan()
395399
assert all(query) == ~s{SELECT count(*) FILTER (WHERE s0.x > 10) FROM schema AS s0}
@@ -969,7 +973,9 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
969973
assert all(query) == ~s{SELECT json_extract(s0.meta, '$.\\"a') FROM schema AS s0}
970974

971975
query = Schema |> select([s], s.meta["author"]["name"]) |> plan()
972-
assert all(query) == ~s{SELECT json_extract(s0.meta, '$.author.name') FROM schema AS s0}
976+
977+
assert all(query) ==
978+
~s{SELECT json_extract(s0.meta, '$.author.name') FROM schema AS s0}
973979
end
974980

975981
test "nested expressions" do
@@ -1026,7 +1032,8 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
10261032
|> select([e], e in [1, 2, 3])
10271033
|> plan()
10281034

1029-
assert all(query) == "SELECT s0 IN (SELECT value FROM JSON_EACH('[1,2,3]')) FROM schema AS s0"
1035+
assert all(query) ==
1036+
"SELECT s0 IN (SELECT value FROM JSON_EACH('[1,2,3]')) FROM schema AS s0"
10301037
end
10311038

10321039
test "in subquery" do
@@ -1297,12 +1304,15 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
12971304
AND (s0.x = 123)\
12981305
"""
12991306

1300-
query = from(
1301-
p in Post,
1302-
where: p.title == ^"foo",
1303-
select: p.content,
1304-
update: [set: [title: "bar"]]
1305-
) |> plan(:update_all)
1307+
query =
1308+
from(
1309+
p in Post,
1310+
where: p.title == ^"foo",
1311+
select: p.content,
1312+
update: [set: [title: "bar"]]
1313+
)
1314+
|> plan(:update_all)
1315+
13061316
assert update_all(query) ==
13071317
"""
13081318
UPDATE posts AS p0 \
@@ -1335,6 +1345,7 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
13351345
from(p in Post, update: [set: [title: "foo"]])
13361346
|> select([p], p)
13371347
|> plan(:update_all)
1348+
13381349
assert update_all(query) ==
13391350
"""
13401351
UPDATE posts AS p0 \
@@ -1347,6 +1358,7 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
13471358
|> where([m], m.x == ^2)
13481359
|> select([m], m.x == ^3)
13491360
|> plan(:update_all)
1361+
13501362
assert update_all(query) ==
13511363
"""
13521364
UPDATE schema AS s0 \
@@ -1375,20 +1387,22 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
13751387
(e in Schema)
13761388
|> from(where: e.x == 123, select: e.x)
13771389
|> plan()
1390+
13781391
assert delete_all(query) ==
1379-
"""
1380-
DELETE FROM schema AS s0 \
1381-
WHERE (s0.x = 123) RETURNING s0.x\
1382-
"""
1392+
"""
1393+
DELETE FROM schema AS s0 \
1394+
WHERE (s0.x = 123) RETURNING s0.x\
1395+
"""
13831396
end
13841397

13851398
test "delete all with returning" do
1386-
query = Post |> Ecto.Queryable.to_query |> select([m], m) |> plan()
1399+
query = Post |> Ecto.Queryable.to_query() |> select([m], m) |> plan()
1400+
13871401
assert delete_all(query) ==
1388-
"""
1389-
DELETE FROM posts AS p0 \
1390-
RETURNING p0.id, p0.title, p0.content\
1391-
"""
1402+
"""
1403+
DELETE FROM posts AS p0 \
1404+
RETURNING p0.id, p0.title, p0.content\
1405+
"""
13921406
end
13931407

13941408
test "delete all with prefix" do
@@ -2095,10 +2109,11 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
20952109
end
20962110

20972111
test "insert with query as rows" do
2098-
query = from(s in "schema", select: %{ foo: fragment("3"), bar: s.bar }) |> plan(:all)
2112+
query = from(s in "schema", select: %{foo: fragment("3"), bar: s.bar}) |> plan(:all)
20992113
query = insert(nil, "schema", [:foo, :bar], query, {:raise, [], []}, [])
21002114

2101-
assert query == ~s{INSERT INTO schema (foo,bar) (SELECT 3, s0.bar FROM schema AS s0)}
2115+
assert query ==
2116+
~s{INSERT INTO schema (foo,bar) (SELECT 3, s0.bar FROM schema AS s0)}
21022117
end
21032118

21042119
# test "update" do
@@ -2198,8 +2213,7 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
21982213
%Reference{table: :categories, with: [here: :there], on_delete: :nilify_all},
21992214
[]},
22002215
{:add, :category_7,
2201-
%Reference{table: :tags, with: [that: :this], on_delete: :nilify_all},
2202-
[]},
2216+
%Reference{table: :tags, with: [that: :this], on_delete: :nilify_all}, []}
22032217
]}
22042218

22052219
assert execute_ddl(create) == [
@@ -2448,11 +2462,11 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
24482462
}
24492463

24502464
assert execute_ddl(alteration) == [
2451-
"""
2452-
ALTER TABLE posts \
2453-
DROP COLUMN price\
2454-
"""
2455-
]
2465+
"""
2466+
ALTER TABLE posts \
2467+
DROP COLUMN price\
2468+
"""
2469+
]
24562470
end
24572471

24582472
test "alter table with primary key" do
@@ -2714,11 +2728,11 @@ defmodule Ecto.Adapters.SQLite3.ConnectionTest do
27142728
drop_column = {:alter, table(:posts), [{:remove, :summary}]}
27152729

27162730
assert execute_ddl(drop_column) == [
2717-
"""
2718-
ALTER TABLE posts \
2719-
DROP COLUMN summary\
2720-
"""
2721-
]
2731+
"""
2732+
ALTER TABLE posts \
2733+
DROP COLUMN summary\
2734+
"""
2735+
]
27222736
end
27232737

27242738
test "arrays" do

0 commit comments

Comments
 (0)