diff --git a/.formatter.exs b/.formatter.exs new file mode 100644 index 0000000..89fb624 --- /dev/null +++ b/.formatter.exs @@ -0,0 +1,7 @@ +[ + import_deps: [:ecto, :ecto_sql], + inputs: [ + "*.{ex,exs}", + "{config,lib,test}/**/*.{ex,exs}" + ] +] diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 44f22c9..c7ca9ca 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -48,3 +48,4 @@ jobs: cp config/test.exs.GH_actions config/test.exs mix ecto.create mix test + mix format --check-formatted diff --git a/README.md b/README.md index afdef18..e705e7e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -[![Build Status](https://travis-ci.org/revelrylabs/ecto_soft_delete.svg?branch=master)](https://travis-ci.org/revelrylabs/ecto_soft_delete) +![Build Status](https://github.com/revelrylabs/ecto_soft_delete/actions/workflows/test.yml/badge.svg) +![Publish Status](https://github.com/revelrylabs/ecto_soft_delete/actions/workflows/publish.yml/badge.svg) [![Hex.pm](https://img.shields.io/hexpm/dt/ecto_soft_delete.svg)](https://hex.pm/packages/ecto_soft_delete) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) -[![Coverage Status](https://opencov.prod.revelry.net/projects/21/badge.svg)](https://opencov.prod.revelry.net/projects/21) # EctoSoftDelete diff --git a/config/config.exs b/config/config.exs index 3e030c2..bb265cd 100644 --- a/config/config.exs +++ b/config/config.exs @@ -27,4 +27,4 @@ import Config # Configuration from the imported file will override the ones defined # here (which is why it is important to import them last). # - import_config "#{Mix.env}.exs" +import_config "#{Mix.env()}.exs" diff --git a/lib/ecto/soft_delete_query.ex b/lib/ecto/soft_delete_query.ex index a6d52f2..f05b1f4 100644 --- a/lib/ecto/soft_delete_query.ex +++ b/lib/ecto/soft_delete_query.ex @@ -14,7 +14,7 @@ defmodule Ecto.SoftDelete.Query do results = Repo.all(query) """ - @spec with_undeleted(Ecto.Queryable.t) :: Ecto.Queryable.t + @spec with_undeleted(Ecto.Queryable.t()) :: Ecto.Queryable.t() def with_undeleted(query) do if soft_deletable?(query) do query @@ -31,7 +31,7 @@ defmodule Ecto.SoftDelete.Query do |> soft_deletable? """ - @spec soft_deletable?(Ecto.Queryable.t) :: boolean() + @spec soft_deletable?(Ecto.Queryable.t()) :: boolean() def soft_deletable?(query) do schema_module = get_schema_module(query) fields = if schema_module, do: schema_module.__schema__(:fields), else: [] @@ -39,14 +39,14 @@ defmodule Ecto.SoftDelete.Query do Enum.member?(fields, :deleted_at) end - @doc""" + @doc """ Returns `true` if the schema is not flagged to skip auto-filtering """ - @spec auto_include_deleted_at_clause?(Ecto.Queriable.t) :: boolean() + @spec auto_include_deleted_at_clause?(Ecto.Queriable.t()) :: boolean() def auto_include_deleted_at_clause?(query) do schema_module = get_schema_module(query) - !Kernel.function_exported?(schema_module, :skip_soft_delete_prepare_query?, 0) || + !Kernel.function_exported?(schema_module, :skip_soft_delete_prepare_query?, 0) || !schema_module.skip_soft_delete_prepare_query?() end diff --git a/mix.exs b/mix.exs index 9b14203..73f02b7 100644 --- a/mix.exs +++ b/mix.exs @@ -4,7 +4,7 @@ defmodule EctoSoftDelete.Mixfile do def project do [ app: :ecto_soft_delete, - version: "2.0.4", + version: "2.1.4", elixir: "~> 1.11", elixirc_paths: elixirc_paths(Mix.env()), build_embedded: Mix.env() == :prod, @@ -48,7 +48,7 @@ defmodule EctoSoftDelete.Mixfile do defp package do [ files: ["lib", "mix.exs", "README.md", "LICENSE", "CHANGELOG.md"], - maintainers: ["Bryan Joseph", "Luke Ledet"], + maintainers: ["Bryan Joseph", "Luke Ledet", "Revelry Labs"], licenses: ["MIT"], links: %{ "GitHub" => "https://github.com/revelrylabs/ecto_soft_delete" diff --git a/test/soft_delete_migration_test.exs b/test/soft_delete_migration_test.exs index 7be3453..a01e72e 100644 --- a/test/soft_delete_migration_test.exs +++ b/test/soft_delete_migration_test.exs @@ -7,7 +7,13 @@ defmodule Ecto.SoftDelete.Migration.Test do setup meta do :ok = Ecto.Adapters.SQL.Sandbox.checkout(Repo) - {:ok, runner} = Runner.start_link({self(), Repo, Repo.config(), __MODULE__, meta[:direction] || :forward, :up, %{level: false, sql: false}}) + + {:ok, runner} = + Runner.start_link( + {self(), Repo, Repo.config(), __MODULE__, meta[:direction] || :forward, :up, + %{level: false, sql: false}} + ) + Runner.metadata(runner, meta) {:ok, runner: runner} end @@ -21,7 +27,6 @@ defmodule Ecto.SoftDelete.Migration.Test do flush() - assert {:create, _, - [{:add, :deleted_at, :utc_datetime_usec, []}]} = create_command + assert {:create, _, [{:add, :deleted_at, :utc_datetime_usec, []}]} = create_command end end diff --git a/test/test_helper.exs b/test/test_helper.exs index b1e8af0..04c1c52 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,5 +1,5 @@ {:ok, _} = Application.ensure_all_started(:postgrex) -{:ok, _pid} = Ecto.SoftDelete.Test.Repo.start_link +{:ok, _pid} = Ecto.SoftDelete.Test.Repo.start_link() defmodule Ecto.SoftDelete.Test.Migrations do use Ecto.Migration @@ -7,6 +7,7 @@ defmodule Ecto.SoftDelete.Test.Migrations do def change do drop_if_exists table(:users) + create table(:users) do add :email, :string soft_delete_columns()