Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
import_deps: [:ecto, :ecto_sql],
inputs: [
"*.{ex,exs}",
"{config,lib,test}/**/*.{ex,exs}"
]
]
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ jobs:
cp config/test.exs.GH_actions config/test.exs
mix ecto.create
mix test
mix format --check-formatted
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
10 changes: 5 additions & 5 deletions lib/ecto/soft_delete_query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,22 +31,22 @@ 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: []

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

Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"
Expand Down
11 changes: 8 additions & 3 deletions test/soft_delete_migration_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
3 changes: 2 additions & 1 deletion test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{: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
import Ecto.SoftDelete.Migration

def change do
drop_if_exists table(:users)

create table(:users) do
add :email, :string
soft_delete_columns()
Expand Down
Loading