From 21fe1324bcf3e0de0c753b357f294e073c6dc4da Mon Sep 17 00:00:00 2001 From: Connor Rigby Date: Mon, 30 Jul 2018 20:41:21 -0700 Subject: [PATCH 01/10] Add new configs and update deps. --- .circleci/config.yml | 43 ++++++++++++++++++++++++++++++ .formatter.exs | 4 +++ .travis.yml | 2 +- config/dogma.exs | 13 --------- lib/sqlite_db_connection/stream.ex | 4 +++ mix.exs | 13 +++++---- mix.lock | 23 ++++++++++------ 7 files changed, 73 insertions(+), 29 deletions(-) create mode 100644 .circleci/config.yml create mode 100644 .formatter.exs delete mode 100644 config/dogma.exs diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..2d3f0a91 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,43 @@ +version: 2 +jobs: + build: + docker: + - image: circleci/elixir:1.6.6 + steps: + - checkout + - restore_cache: + keys: + - v1-dependency-cache-{{ checksum "mix.lock" }} + - v1-dependency-cache + - run: mix local.hex --force + - run: mix local.rebar --force + - run: mix deps.get + - run: mix deps.compile --warnings-as-errors + - run: mix compile + - run: + command: mix compile --warnings-as-errors + environment: + MIX_ENV: test + - restore_cache: + keys: + - v1-plt-cache-{{ checksum "mix.lock" }} + - v1-plt-cache + - run: mix dialyzer --plt + - run: mix dialyzer --halt-exit-status + - run: mix credo --strict --ignore linelength -a + - run: + command: mix coveralls.circle --include bench + environment: + MIX_ENV: test + - save_cache: + key: v1-plt-cache-{{ checksum "mix.lock" }} + paths: + - _build + - deps + - ~/.mix + - save_cache: + key: v1-dependency-cache-{{ checksum "mix.lock" }} + paths: + - _build + - deps + - ~/.mix diff --git a/.formatter.exs b/.formatter.exs new file mode 100644 index 00000000..893372c1 --- /dev/null +++ b/.formatter.exs @@ -0,0 +1,4 @@ +# Used by "mix format" +[ + inputs: ["mix.exs", "{config,lib,test,bench}/**/*.{ex,exs}"] +] diff --git a/.travis.yml b/.travis.yml index 0d45002a..a7f67f5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ matrix: script: - mix deps.get && ./integration/hack_out_incompatible_tests.sh && mix test --cover - - mix dogma + - mix format --check-formatted branches: only: diff --git a/config/dogma.exs b/config/dogma.exs deleted file mode 100644 index de3496e6..00000000 --- a/config/dogma.exs +++ /dev/null @@ -1,13 +0,0 @@ -use Mix.Config -alias Dogma.Rule - -config :dogma, - rule_set: Dogma.RuleSet.All, - - override: [ - %Rule.CommentFormat{enabled: false}, - %Rule.FunctionArity{enabled: false}, - %Rule.LineLength{enabled: false}, - %Rule.PipelineStart{enabled: false}, - %Rule.QuotesInString{enabled: false}, - ] diff --git a/lib/sqlite_db_connection/stream.ex b/lib/sqlite_db_connection/stream.ex index 40c73c02..eb08029d 100644 --- a/lib/sqlite_db_connection/stream.ex +++ b/lib/sqlite_db_connection/stream.ex @@ -29,4 +29,8 @@ defimpl Enumerable, for: Sqlite.DbConnection.Stream do def count(_) do {:error, __MODULE__} end + + def slice(_) do + {:error, __MODULE__} + end end diff --git a/mix.exs b/mix.exs index 83341653..1bd5bac0 100644 --- a/mix.exs +++ b/mix.exs @@ -33,15 +33,14 @@ defmodule Sqlite.Ecto2.Mixfile do defp deps do [{:connection, "~> 1.0.3"}, {:coverex, "~> 1.4.11", only: :test}, - {:credo, "~> 0.7", only: [:dev, :test]}, + {:credo, "~> 0.10", only: [:dev, :test]}, {:db_connection, "~> 1.1.0"}, - {:decimal, "~> 1.2"}, - {:dogma, "~> 0.1", only: :dev}, - {:esqlite, "~> 0.2.3"}, - {:ex_doc, "~> 0.16", only: :dev}, - {:ecto, "~> 2.2.2"}, + {:decimal, "~> 1.5"}, + {:esqlite, github: "Sqlite-Ecto/esqlite", override: true}, + {:ex_doc, "~> 0.18", runtime: false, only: :docs}, + {:ecto, "~> 2.2"}, {:poison, "~> 2.2 or ~> 3.0", optional: true}, - {:postgrex, "~> 0.13.0", optional: true}, + {:postgrex, "~> 0.13", optional: true}, {:sbroker, "~> 1.0"}, {:sqlitex, "~> 1.3.2 or ~> 1.4"}] end diff --git a/mix.lock b/mix.lock index 183e689b..e9b5846c 100644 --- a/mix.lock +++ b/mix.lock @@ -1,22 +1,29 @@ -%{"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"}, +%{ + "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"}, "certifi": {:hex, :certifi, "1.0.0", "1c787a85b1855ba354f0b8920392c19aa1d06b0ee1362f9141279620a5be2039", [:rebar3], [], "hexpm"}, "connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm"}, "coverex": {:hex, :coverex, "1.4.13", "d90833b82bdd6a1ec05a6d971283debc3dd9611957489010e4b1ab0071a9ee6c", [:mix], [{:hackney, "~> 1.5", [hex: :hackney, repo: "hexpm", optional: false]}, {:poison, "~> 1.5 or ~> 2.0 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, - "credo": {:hex, :credo, "0.8.1", "137efcc99b4bc507c958ba9b5dff70149e971250813cbe7d4537ec7e36997402", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"}, + "credo": {:hex, :credo, "0.10.0", "66234a95effaf9067edb19fc5d0cd5c6b461ad841baac42467afed96c78e5e9e", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, "db_connection": {:hex, :db_connection, "1.1.2", "2865c2a4bae0714e2213a0ce60a1b12d76a6efba0c51fbda59c9ab8d1accc7a8", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"}, - "decimal": {:hex, :decimal, "1.4.0", "fac965ce71a46aab53d3a6ce45662806bdd708a4a95a65cde8a12eb0124a1333", [:mix], [], "hexpm"}, - "dogma": {:hex, :dogma, "0.1.15", "5bceba9054b2b97a4adcb2ab4948ca9245e5258b883946e82d32f785340fd411", [:mix], [{:poison, ">= 2.0.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, - "earmark": {:hex, :earmark, "1.2.2", "f718159d6b65068e8daeef709ccddae5f7fdc770707d82e7d126f584cd925b74", [:mix], [], "hexpm"}, + "decimal": {:hex, :decimal, "1.5.0", "b0433a36d0e2430e3d50291b1c65f53c37d56f83665b43d79963684865beab68", [:mix], [], "hexpm"}, + "dogma": {:hex, :dogma, "0.1.16", "3c1532e2f63ece4813fe900a16704b8e33264da35fdb0d8a1d05090a3022eef9", [:mix], [{:poison, ">= 2.0.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, + "earmark": {:hex, :earmark, "1.2.5", "4d21980d5d2862a2e13ec3c49ad9ad783ffc7ca5769cf6ff891a4553fbaae761", [:mix], [], "hexpm"}, "ecto": {:hex, :ecto, "2.2.2", "e9bd6ebc044eaaab1cb369e3465686d8aca830aa5bf545ef2bae000a3d42c54b", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"}, - "esqlite": {:hex, :esqlite, "0.2.3", "1a8b60877fdd3d50a8a84b342db04032c0231cc27ecff4ddd0d934485d4c0cd5", [:rebar3], [], "hexpm"}, - "ex_doc": {:hex, :ex_doc, "0.16.3", "cd2a4cfe5d26e37502d3ec776702c72efa1adfa24ed9ce723bb565f4c30bd31a", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"}, + "elixir_make": {:hex, :elixir_make, "0.4.2", "332c649d08c18bc1ecc73b1befc68c647136de4f340b548844efc796405743bf", [:mix], [], "hexpm"}, + "esqlite": {:git, "https://github.com/Sqlite-Ecto/esqlite.git", "99c0905d2c2e73851c087172ccbec0418f5a4d5e", []}, + "ex_doc": {:hex, :ex_doc, "0.19.0", "e22b6434373b4870ea77b24df069dbac7002c1f483615e9ebfc0c37497e1c75c", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.7", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"}, "hackney": {:hex, :hackney, "1.7.1", "e238c52c5df3c3b16ce613d3a51c7220a784d734879b1e231c9babd433ac1cb4", [:rebar3], [{:certifi, "1.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "4.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, "idna": {:hex, :idna, "4.0.0", "10aaa9f79d0b12cf0def53038547855b91144f1bfcc0ec73494f38bb7b9c4961", [:rebar3], [], "hexpm"}, + "jason": {:hex, :jason, "1.1.1", "d3ccb840dfb06f2f90a6d335b536dd074db748b3e7f5b11ab61d239506585eb2", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"}, + "makeup": {:hex, :makeup, "0.5.1", "966c5c2296da272d42f1de178c1d135e432662eca795d6dc12e5e8787514edf7", [:mix], [{:nimble_parsec, "~> 0.2.2", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.8.0", "1204a2f5b4f181775a0e456154830524cf2207cf4f9112215c05e0b76e4eca8b", [:mix], [{:makeup, "~> 0.5.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 0.2.2", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm"}, "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], [], "hexpm"}, + "nimble_parsec": {:hex, :nimble_parsec, "0.2.2", "d526b23bdceb04c7ad15b33c57c4526bf5f50aaa70c7c141b4b4624555c68259", [:mix], [], "hexpm"}, "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm"}, "poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], [], "hexpm"}, "postgrex": {:hex, :postgrex, "0.13.3", "c277cfb2a9c5034d445a722494c13359e361d344ef6f25d604c2353185682bfc", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm"}, "sbroker": {:hex, :sbroker, "1.0.0", "28ff1b5e58887c5098539f236307b36fe1d3edaa2acff9d6a3d17c2dcafebbd0", [:rebar3], [], "hexpm"}, "sqlitex": {:hex, :sqlitex, "1.3.2", "ec4c78306dcc2c45761b9c1bdf2864ab3f18e077d31c84aa8aed5dc76841c535", [:mix], [{:decimal, "~> 1.1", [hex: :decimal, repo: "hexpm", optional: false]}, {:esqlite, "~> 0.2.3", [hex: :esqlite, repo: "hexpm", optional: false]}], "hexpm"}, - "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"}} + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], [], "hexpm"}, +} From 956aa795ec756814a0fdc544c736a08fb209e996 Mon Sep 17 00:00:00 2001 From: connor rigby Date: Wed, 1 Aug 2018 10:46:17 -0700 Subject: [PATCH 02/10] Update circleci config --- .circleci/config.yml | 35 +++++++---------------------------- mix.lock | 2 +- 2 files changed, 8 insertions(+), 29 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2d3f0a91..f311ed5e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,43 +1,22 @@ -version: 2 +version: 2.0 jobs: build: docker: - - image: circleci/elixir:1.6.6 + - image: circleci/elixir:1.6.6-otp-21 steps: - checkout - restore_cache: keys: - - v1-dependency-cache-{{ checksum "mix.lock" }} - - v1-dependency-cache + - v2-dependency-cache-{{ checksum "mix.lock" }} - run: mix local.hex --force - run: mix local.rebar --force - run: mix deps.get - - run: mix deps.compile --warnings-as-errors + - run: mix deps.compile - run: mix compile - - run: - command: mix compile --warnings-as-errors - environment: - MIX_ENV: test - - restore_cache: - keys: - - v1-plt-cache-{{ checksum "mix.lock" }} - - v1-plt-cache - - run: mix dialyzer --plt - - run: mix dialyzer --halt-exit-status - - run: mix credo --strict --ignore linelength -a - - run: - command: mix coveralls.circle --include bench - environment: - MIX_ENV: test - - save_cache: - key: v1-plt-cache-{{ checksum "mix.lock" }} - paths: - - _build - - deps - - ~/.mix + - run: ./integration/hack_out_incompatible_tests.sh + - run: mix coveralls.circle - save_cache: - key: v1-dependency-cache-{{ checksum "mix.lock" }} + key: v2-dependency-cache-{{ checksum "mix.lock" }} paths: - _build - deps - - ~/.mix diff --git a/mix.lock b/mix.lock index e9b5846c..52b0c273 100644 --- a/mix.lock +++ b/mix.lock @@ -10,7 +10,7 @@ "earmark": {:hex, :earmark, "1.2.5", "4d21980d5d2862a2e13ec3c49ad9ad783ffc7ca5769cf6ff891a4553fbaae761", [:mix], [], "hexpm"}, "ecto": {:hex, :ecto, "2.2.2", "e9bd6ebc044eaaab1cb369e3465686d8aca830aa5bf545ef2bae000a3d42c54b", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"}, "elixir_make": {:hex, :elixir_make, "0.4.2", "332c649d08c18bc1ecc73b1befc68c647136de4f340b548844efc796405743bf", [:mix], [], "hexpm"}, - "esqlite": {:git, "https://github.com/Sqlite-Ecto/esqlite.git", "99c0905d2c2e73851c087172ccbec0418f5a4d5e", []}, + "esqlite": {:git, "https://github.com/Sqlite-Ecto/esqlite.git", "a8e2bfd80143d3be0c29944b52c1bda53858d08b", []}, "ex_doc": {:hex, :ex_doc, "0.19.0", "e22b6434373b4870ea77b24df069dbac7002c1f483615e9ebfc0c37497e1c75c", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.7", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"}, "hackney": {:hex, :hackney, "1.7.1", "e238c52c5df3c3b16ce613d3a51c7220a784d734879b1e231c9babd433ac1cb4", [:rebar3], [{:certifi, "1.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "4.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, "idna": {:hex, :idna, "4.0.0", "10aaa9f79d0b12cf0def53038547855b91144f1bfcc0ec73494f38bb7b9c4961", [:rebar3], [], "hexpm"}, From 6d6cfffe36b0c6599da0a318efb6b5ce2ec91d1c Mon Sep 17 00:00:00 2001 From: connor rigby Date: Wed, 1 Aug 2018 10:50:42 -0700 Subject: [PATCH 03/10] Update Readme. --- mix.exs | 14 ++++++++++---- mix.lock | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mix.exs b/mix.exs index 1bd5bac0..92483c6d 100644 --- a/mix.exs +++ b/mix.exs @@ -13,7 +13,13 @@ defmodule Sqlite.Ecto2.Mixfile do # testing build_per_environment: false, test_paths: test_paths(), - test_coverage: [tool: Coverex.Task, coveralls: true], + test_coverage: [tool: ExCoveralls], + preferred_cli_env: [ + coveralls: :test, + "coveralls.detail": :test, + "coveralls.html": :test, + "coveralls.circle": :test + ], # hex description: description(), @@ -32,11 +38,11 @@ defmodule Sqlite.Ecto2.Mixfile do # Dependencies defp deps do [{:connection, "~> 1.0.3"}, - {:coverex, "~> 1.4.11", only: :test}, {:credo, "~> 0.10", only: [:dev, :test]}, {:db_connection, "~> 1.1.0"}, {:decimal, "~> 1.5"}, {:esqlite, github: "Sqlite-Ecto/esqlite", override: true}, + {:excoveralls, "~> 0.9", only: :test}, {:ex_doc, "~> 0.18", runtime: false, only: :docs}, {:ecto, "~> 2.2"}, {:poison, "~> 2.2 or ~> 3.0", optional: true}, @@ -48,9 +54,9 @@ defmodule Sqlite.Ecto2.Mixfile do defp description, do: "SQLite3 adapter for Ecto2" defp package do - [maintainers: ["Eric Scouten", "Jason M Barnes"], + [maintainers: ["Eric Scouten", "Jason M Barnes", "Connor Rigby"], licenses: ["MIT"], - links: %{"Github" => "https://github.com/scouten/sqlite_ecto2"}] + links: %{"Github" => "https://github.com/Sqlite-Ecto/sqlite_ecto2"}] end defp elixirc_paths(:test), do: ["lib", "test/sqlite_db_connection/support"] diff --git a/mix.lock b/mix.lock index 52b0c273..63611a12 100644 --- a/mix.lock +++ b/mix.lock @@ -12,6 +12,7 @@ "elixir_make": {:hex, :elixir_make, "0.4.2", "332c649d08c18bc1ecc73b1befc68c647136de4f340b548844efc796405743bf", [:mix], [], "hexpm"}, "esqlite": {:git, "https://github.com/Sqlite-Ecto/esqlite.git", "a8e2bfd80143d3be0c29944b52c1bda53858d08b", []}, "ex_doc": {:hex, :ex_doc, "0.19.0", "e22b6434373b4870ea77b24df069dbac7002c1f483615e9ebfc0c37497e1c75c", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.7", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"}, + "excoveralls": {:hex, :excoveralls, "0.9.1", "14fd20fac51ab98d8e79615814cc9811888d2d7b28e85aa90ff2e30dcf3191d6", [:mix], [{:hackney, ">= 0.12.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, "hackney": {:hex, :hackney, "1.7.1", "e238c52c5df3c3b16ce613d3a51c7220a784d734879b1e231c9babd433ac1cb4", [:rebar3], [{:certifi, "1.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "4.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, "idna": {:hex, :idna, "4.0.0", "10aaa9f79d0b12cf0def53038547855b91144f1bfcc0ec73494f38bb7b9c4961", [:rebar3], [], "hexpm"}, "jason": {:hex, :jason, "1.1.1", "d3ccb840dfb06f2f90a6d335b536dd074db748b3e7f5b11ab61d239506585eb2", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"}, From 876685506c89595819ab54292cea7817c0bb51cc Mon Sep 17 00:00:00 2001 From: connor rigby Date: Wed, 1 Aug 2018 10:51:42 -0700 Subject: [PATCH 04/10] Add tool versions file --- .tool-versions | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .tool-versions diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 00000000..f2f85981 --- /dev/null +++ b/.tool-versions @@ -0,0 +1,2 @@ +erlang 21.0.1 +elixir 1.6.6-otp-21 From b9e7c983ace5b05a0193b0d1e91f6e8b531eeee4 Mon Sep 17 00:00:00 2001 From: connor rigby Date: Wed, 1 Aug 2018 10:57:07 -0700 Subject: [PATCH 05/10] Update circleci config --- .circleci/config.yml | 1 + .credo.exs | 4 ---- .travis.yml | 25 ------------------------- lib/sqlite_ecto/connection.ex | 4 ++-- 4 files changed, 3 insertions(+), 31 deletions(-) delete mode 100644 .travis.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index f311ed5e..f89fac0c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,6 +14,7 @@ jobs: - run: mix deps.compile - run: mix compile - run: ./integration/hack_out_incompatible_tests.sh + - run: mix credo --strict - run: mix coveralls.circle - save_cache: key: v2-dependency-cache-{{ checksum "mix.lock" }} diff --git a/.credo.exs b/.credo.exs index f7956502..76c3fdbd 100644 --- a/.credo.exs +++ b/.credo.exs @@ -72,10 +72,6 @@ {Credo.Check.Warning.BoolOperationOnSameValues}, {Credo.Check.Warning.IExPry}, {Credo.Check.Warning.IoInspect, false}, - {Credo.Check.Warning.NameRedeclarationByAssignment, false}, - {Credo.Check.Warning.NameRedeclarationByCase, false}, - {Credo.Check.Warning.NameRedeclarationByDef, false}, - {Credo.Check.Warning.NameRedeclarationByFn, false}, {Credo.Check.Warning.OperationOnSameValues, false}, # Disabled because of p.x == p.x in Ecto queries {Credo.Check.Warning.OperationWithConstantResult}, diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a7f67f5e..00000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: elixir - -elixir: - - 1.4.4 - - 1.5.1 - -otp_release: - - 18.2 - - 19.3 - - 20.0 - -matrix: - exclude: - - elixir: 1.4.4 - otp_release: 20.0 - - elixir: 1.5.1 - otp_release: 18.2 - -script: - - mix deps.get && ./integration/hack_out_incompatible_tests.sh && mix test --cover - - mix format --check-formatted - -branches: - only: - - master diff --git a/lib/sqlite_ecto/connection.ex b/lib/sqlite_ecto/connection.ex index 6d57369f..598fe7fb 100644 --- a/lib/sqlite_ecto/connection.ex +++ b/lib/sqlite_ecto/connection.ex @@ -565,10 +565,10 @@ if Code.ensure_loaded?(Sqlitex.Server) do # DDL - alias Ecto.Migration.Table + alias Ecto.Migration.Constraint alias Ecto.Migration.Index alias Ecto.Migration.Reference - alias Ecto.Migration.Constraint + alias Ecto.Migration.Table @drops [:drop, :drop_if_exists] From 77d052d1a429ca7f401860d87978d87d7a90d284 Mon Sep 17 00:00:00 2001 From: connor rigby Date: Wed, 1 Aug 2018 11:06:08 -0700 Subject: [PATCH 06/10] Update Readme --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index dbc34c59..e5625f33 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ -[![Build Status](https://travis-ci.org/scouten/sqlite_ecto2.svg?branch=master "Build Status")](https://travis-ci.org/scouten/sqlite_ecto2) +[![CircleCI](https://circleci.com/gh/Sqlite-Ecto/sqlite_ecto2.svg?style=svg)](https://circleci.com/gh/Sqlite-Ecto/sqlite_ecto2) [![Hex.pm](https://img.shields.io/hexpm/v/sqlite_ecto2.svg)](https://hex.pm/packages/sqlite_ecto2) -[![Ebert](https://ebertapp.io/github/scouten/sqlite_ecto2.svg)](https://ebertapp.io/github/scouten/sqlite_ecto2) -[![Coverage Status](https://coveralls.io/repos/github/scouten/sqlite_ecto2/badge.svg?branch=master)](https://coveralls.io/github/scouten/sqlite_ecto2?branch=master) +[![Coverage Status](https://coveralls.io/repos/github/Sqlite-Ecto/sqlite_ecto2/badge.svg?branch=master)](https://coveralls.io/github/Sqlite-Ecto/sqlite_ecto2?branch=master) # sqlite_ecto2 @@ -21,7 +20,7 @@ I'll review PRs from time to time if they can be merged easily, but I do not hav **IMPORTANT:** This release will _only_ work with Ecto 2.2.x. If you need compatibility with older versions of Ecto, please see: -* Ecto 2.1.x -> [`sqlite_ecto2` 2.0.x series](https://github.com/scouten/sqlite_ecto2/tree/v2.0) +* Ecto 2.1.x -> [`sqlite_ecto2` 2.0.x series](https://github.com/Sqlite-Ecto/sqlite_ecto2/tree/v2.0) * Ecto 1.x -> [`sqlite_ecto` v1.x series](https://github.com/jazzyb/sqlite_ecto) @@ -62,7 +61,8 @@ Note that the Travis configuration for this repo specifically excludes OTP 19.0 ## Dependencies -This library makes use of [sqlitex](https://github.com/mmmries/sqlitex) and [esqlite](https://github.com/mmzeeman/esqlite). Since esqlite uses Erlang NIFs to incorporate SQLite, you will need a valid C compiler to build the library. +This library makes use of [sqlite3](https://github.com/Sqlite-Ecto/sqlitex) +Since esqlite uses Erlang NIFs to incorporate SQLite, you will need a valid C compiler to build the library. ## Example From 9deb8a7d43a7953da9d8a3830c7f1d53ddd96358 Mon Sep 17 00:00:00 2001 From: Connor Rigby Date: Sat, 4 Aug 2018 16:40:11 -0700 Subject: [PATCH 07/10] Remove unneeded config. --- mix.exs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mix.exs b/mix.exs index 92483c6d..c19261c1 100644 --- a/mix.exs +++ b/mix.exs @@ -31,7 +31,7 @@ defmodule Sqlite.Ecto2.Mixfile do # Configuration for the OTP application def application do - [applications: [:db_connection, :ecto, :logger, :sqlitex], + [extra_applications: [:logger], mod: {Sqlite.DbConnection.App, []}] end @@ -41,7 +41,6 @@ defmodule Sqlite.Ecto2.Mixfile do {:credo, "~> 0.10", only: [:dev, :test]}, {:db_connection, "~> 1.1.0"}, {:decimal, "~> 1.5"}, - {:esqlite, github: "Sqlite-Ecto/esqlite", override: true}, {:excoveralls, "~> 0.9", only: :test}, {:ex_doc, "~> 0.18", runtime: false, only: :docs}, {:ecto, "~> 2.2"}, From 5333c6711a9ccfe9a6e1a65aad14ea8fdd9be198 Mon Sep 17 00:00:00 2001 From: Connor Rigby Date: Sat, 4 Aug 2018 16:44:58 -0700 Subject: [PATCH 08/10] Update Readme. --- README.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/README.md b/README.md index e5625f33..9fd0fa58 100644 --- a/README.md +++ b/README.md @@ -9,13 +9,6 @@ Read [the tutorial](./docs/tutorial.md) for a detailed example of how to setup and use a SQLite repo with Ecto, or just check-out the CliffsNotes in the sections below if you want to get started quickly. -## SEEKING NEW MAINTAINER - -My sincere apologies, but I must step down from maintaining this project. Some life events have conspired to leave me without the time I would need to devote to properly continue the development of this project. If you are interested in giving it the love it needs (especially, following the changes for Ecto 3.0), please file an issue or contact me at to discuss taking ownership of this module. - -I'll review PRs from time to time if they can be merged easily, but I do not have the ability to review or attempt to fix unsolved issues. - - ## Ecto Version Compatibility **IMPORTANT:** This release will _only_ work with Ecto 2.2.x. If you need compatibility with older versions of Ecto, please see: From 73ea496f688e7b7e843c55146a8ce1ea8ddcd79e Mon Sep 17 00:00:00 2001 From: Connor Rigby Date: Sat, 4 Aug 2018 16:48:57 -0700 Subject: [PATCH 09/10] Update lock file --- mix.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mix.lock b/mix.lock index 63611a12..4a3dca35 100644 --- a/mix.lock +++ b/mix.lock @@ -10,7 +10,7 @@ "earmark": {:hex, :earmark, "1.2.5", "4d21980d5d2862a2e13ec3c49ad9ad783ffc7ca5769cf6ff891a4553fbaae761", [:mix], [], "hexpm"}, "ecto": {:hex, :ecto, "2.2.2", "e9bd6ebc044eaaab1cb369e3465686d8aca830aa5bf545ef2bae000a3d42c54b", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"}, "elixir_make": {:hex, :elixir_make, "0.4.2", "332c649d08c18bc1ecc73b1befc68c647136de4f340b548844efc796405743bf", [:mix], [], "hexpm"}, - "esqlite": {:git, "https://github.com/Sqlite-Ecto/esqlite.git", "a8e2bfd80143d3be0c29944b52c1bda53858d08b", []}, + "esqlite": {:hex, :esqlite, "0.2.4", "3a8a352c190afe2d6b828b252a6fbff65b5cc1124647f38b15bdab3bf6fd4b3e", [:rebar3], [], "hexpm"}, "ex_doc": {:hex, :ex_doc, "0.19.0", "e22b6434373b4870ea77b24df069dbac7002c1f483615e9ebfc0c37497e1c75c", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.7", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"}, "excoveralls": {:hex, :excoveralls, "0.9.1", "14fd20fac51ab98d8e79615814cc9811888d2d7b28e85aa90ff2e30dcf3191d6", [:mix], [{:hackney, ">= 0.12.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm"}, "hackney": {:hex, :hackney, "1.7.1", "e238c52c5df3c3b16ce613d3a51c7220a784d734879b1e231c9babd433ac1cb4", [:rebar3], [{:certifi, "1.0.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "4.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm"}, From bc3633e1012933302fe1a80f80ea45f4aabcef1b Mon Sep 17 00:00:00 2001 From: Connor Rigby Date: Sat, 4 Aug 2018 16:39:49 -0700 Subject: [PATCH 10/10] Add default timeout for querys, and fix case clause error on timeout --- lib/sqlite_db_connection/protocol.ex | 39 ++++++++++++++++++---------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/lib/sqlite_db_connection/protocol.ex b/lib/sqlite_db_connection/protocol.ex index 3a69e809..eff6a4fb 100644 --- a/lib/sqlite_db_connection/protocol.ex +++ b/lib/sqlite_db_connection/protocol.ex @@ -10,9 +10,10 @@ defmodule Sqlite.DbConnection.Protocol do @spec connect(Keyword.t) :: {:ok, state} def connect(opts) do - {db_path, _opts} = Keyword.pop(opts, :database) + db_path = Keyword.fetch!(opts, :database) + db_timeout = Keyword.get(opts, :db_timeout, 5000) - {:ok, db} = Sqlitex.Server.start_link(db_path) + {:ok, db} = Sqlitex.Server.start_link(db_path, db_timeout: db_timeout) :ok = Sqlitex.Server.exec(db, "PRAGMA foreign_keys = ON") {:ok, [[foreign_keys: 1]]} = Sqlitex.Server.query(db, "PRAGMA foreign_keys") @@ -81,7 +82,7 @@ defmodule Sqlite.DbConnection.Protocol do :transaction -> "BEGIN" :savepoint -> "SAVEPOINT sqlite_ecto_savepoint" end - handle_transaction(sql, s) + handle_transaction(sql, [timeout: Keyword.get(opts, :timeout, 5000)], s) end @spec handle_commit(Keyword.t, state) :: @@ -91,7 +92,7 @@ defmodule Sqlite.DbConnection.Protocol do :transaction -> "COMMIT" :savepoint -> "RELEASE SAVEPOINT sqlite_ecto_savepoint" end - handle_transaction(sql, s) + handle_transaction(sql, [timeout: Keyword.get(opts, :timeout, 5000)], s) end @spec handle_rollback(Keyword.t, state) :: @@ -101,7 +102,7 @@ defmodule Sqlite.DbConnection.Protocol do :transaction -> "ROLLBACK" :savepoint -> "ROLLBACK TO SAVEPOINT sqlite_ecto_savepoint" end - handle_transaction(sql, s) + handle_transaction(sql, [timeout: Keyword.get(opts, :timeout, 5000)], s) end defp refined_info(prepared_info) do @@ -125,10 +126,10 @@ defmodule Sqlite.DbConnection.Protocol do defp maybe_atom_to_lc_string(nil), do: nil defp maybe_atom_to_lc_string(item), do: item |> to_string |> String.downcase - defp handle_execute(%Query{statement: sql}, params, _sync, _opts, s) do + defp handle_execute(%Query{statement: sql}, params, _sync, opts, s) do # Note that we rely on Sqlitex.Server to cache the prepared statement, # so we can simply refer to the original SQL statement here. - case run_stmt(sql, params, s) do + case run_stmt(sql, params, opts, s) do {:ok, result} -> {:ok, result, s} other -> @@ -145,10 +146,16 @@ defmodule Sqlite.DbConnection.Protocol do message: to_string(message)}, s} end - defp run_stmt(query, params, s) do - opts = [decode: :manual, types: true, bind: params] + defp run_stmt(query, params, opts, s) do + query_opts = [ + timeout: Keyword.get(opts, :timeout, 5000), + decode: :manual, + types: true, + bind: params + ] + command = command_from_sql(query) - case query_rows(s.db, to_string(query), opts) do + case query_rows(s.db, to_string(query), query_opts) do {:ok, %{rows: raw_rows, columns: raw_column_names}} -> {rows, num_rows, column_names} = case {raw_rows, raw_column_names} do {_, []} -> {nil, get_changes_count(s.db, command), nil} @@ -160,6 +167,8 @@ defmodule Sqlite.DbConnection.Protocol do command: command}} {:error, {_sqlite_errcode, _message}} = err -> sqlite_error(err, s) + {:error, %Sqlite.DbConnection.Error{} = err} -> + {:error, err, s} {:error, :args_wrong_length} -> {:error, %ArgumentError{message: "parameters must match number of placeholders in query"}, @@ -193,8 +202,8 @@ defmodule Sqlite.DbConnection.Protocol do String.to_atom(List.first(words)) end - defp handle_transaction(stmt, s) do - {:ok, _rows} = query_rows(s.db, stmt, into: :raw_list) + defp handle_transaction(stmt, opts, s) do + {:ok, _rows} = query_rows(s.db, stmt, Keyword.merge(opts, [into: :raw_list])) command = command_from_sql(stmt) result = %Sqlite.DbConnection.Result{rows: nil, num_rows: nil, @@ -207,8 +216,10 @@ defmodule Sqlite.DbConnection.Protocol do try do Sqlitex.Server.query_rows(db, stmt, opts) catch - :exit, _ -> - {:raise, %Sqlite.DbConnection.Error{message: "Disconnected"}} + :exit, {:timeout, _gen_server_call} -> + {:error, %Sqlite.DbConnection.Error{message: "Timeout"}} + :exit, _ex -> + {:error, %Sqlite.DbConnection.Error{message: "Disconnected"}} end end end