-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
108 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Publish | ||
|
||
on: | ||
push: | ||
tags: [ 'v*.*.*' ] | ||
branches: master | ||
|
||
env: | ||
OTP_VERSION_SPEC: "21.1" | ||
ELIXIR_VERSION_SPEC: "1.9.4" | ||
|
||
jobs: | ||
test: | ||
uses: ./.github/workflows/test.yml | ||
publish: | ||
needs: test | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- uses: erlef/setup-beam@v1 | ||
with: | ||
otp-version: ${{ env.OTP_VERSION_SPEC }} | ||
elixir-version: ${{ env.ELIXIR_VERSION_SPEC }} | ||
|
||
# https://hex.pm/docs/publish | ||
- name: Publish | ||
env: | ||
HEX_API_KEY: ${{ secrets.HEX_API_KEY }} | ||
run: | | ||
mix deps.get | ||
mix hex.publish --yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Test | ||
|
||
on: [push, workflow_call] | ||
|
||
env: | ||
OTP_VERSION_SPEC: "21.1" | ||
ELIXIR_VERSION_SPEC: "1.9.4" | ||
MIX_ENV: test | ||
PGUSER: postgres | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_HOST: localhost | ||
POSTGRES_PORT: 5432 | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-20.04 | ||
services: | ||
postgres: | ||
env: | ||
POSTGRES_HOST_AUTH_METHOD: trust | ||
image: postgres:9.5 | ||
ports: | ||
- 5432:5432 | ||
options: >- | ||
--health-cmd pg_isready --health-interval 10s | ||
--health-timeout 5s --health-retries 5 | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- uses: erlef/setup-beam@v1 | ||
with: | ||
otp-version: ${{ env.OTP_VERSION_SPEC }} | ||
elixir-version: ${{ env.ELIXIR_VERSION_SPEC }} | ||
|
||
- name: Run Tests | ||
run: | | ||
mix deps.get | ||
cp config/test.exs.GH_actions config/test.exs | ||
mix ecto.create | ||
mix test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,5 +136,27 @@ defmodule Ecto.SoftDelete.Repo.Test do | |
|
||
assert length(results) == 1 | ||
end | ||
|
||
test "returns same result for different types of where clauses" do | ||
_user = Repo.insert!(%User{email: "[email protected]"}) | ||
|
||
_soft_deleted_user = | ||
Repo.insert!(%User{email: "[email protected]", deleted_at: DateTime.utc_now()}) | ||
|
||
query_1 = | ||
from(u in User, | ||
select: u, | ||
where: u.email == "[email protected]" and not is_nil(u.deleted_at) | ||
) | ||
|
||
query_2 = | ||
from(u in User, | ||
select: u, | ||
where: u.email == "[email protected]", | ||
where: not is_nil(u.deleted_at) | ||
) | ||
|
||
assert Repo.all(query_2) == Repo.all(query_1) | ||
end | ||
end | ||
end |