Skip to content

Commit

Permalink
skip ilike operator tests for sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
woylie committed Sep 12, 2024
1 parent 1f740c5 commit 6f71cd9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/flop.ex
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ defmodule Flop do
...> %{name: "Patty", age: 2, species: "C. aegagrus"}
...> ])
iex>
iex> params = %{filters: [%{field: :name, op: :=~, value: "Mag"}]}
iex> params = %{filters: [%{field: :name, op: :like, value: "Mag"}]}
iex> {:ok, {results, meta}} = Flop.validate_and_run(MyApp.Pet, params)
iex> meta.total_count
1
Expand Down
49 changes: 43 additions & 6 deletions test/adapters/ecto/cases/flop_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -404,31 +404,64 @@ defmodule Flop.Adapters.Ecto.FlopTest do
end
end

test "escapes % in (i)like queries" do
test "escapes % in like queries" do
%{id: _id1} = insert(:pet, name: "abc")
%{id: id2} = insert(:pet, name: "a%c")

for op <- [:like, :ilike, :like_and, :like_or, :ilike_and, :ilike_or] do
for op <- [:like, :like_and, :like_or] do
flop = %Flop{filters: [%Filter{field: :name, op: op, value: "a%c"}]}
assert [%Pet{id: ^id2}] = Flop.all(Pet, flop)
end
end

test "escapes _ in (i)like queries" do
@tag :ilike
test "escapes % in ilike queries" do
%{id: _id1} = insert(:pet, name: "abc")
%{id: id2} = insert(:pet, name: "a%c")

for op <- [:ilike, :ilike_and, :ilike_or] do
flop = %Flop{filters: [%Filter{field: :name, op: op, value: "a%c"}]}
assert [%Pet{id: ^id2}] = Flop.all(Pet, flop)
end
end

test "escapes _ in like queries" do
%{id: _id1} = insert(:pet, name: "abc")
%{id: id2} = insert(:pet, name: "a_c")

for op <- [:like, :like_and, :like_or] do
flop = %Flop{filters: [%Filter{field: :name, op: op, value: "a_c"}]}
assert [%Pet{id: ^id2}] = Flop.all(Pet, flop)
end
end

@tag :ilike
test "escapes _ in ilike queries" do
%{id: _id1} = insert(:pet, name: "abc")
%{id: id2} = insert(:pet, name: "a_c")

for op <- [:like, :ilike, :like_and, :like_or, :ilike_and, :ilike_or] do
for op <- [:ilike, :ilike_and, :ilike_or] do
flop = %Flop{filters: [%Filter{field: :name, op: op, value: "a_c"}]}
assert [%Pet{id: ^id2}] = Flop.all(Pet, flop)
end
end

test "escapes \\ in (i)like queries" do
test "escapes \\ in like queries" do
%{id: _id1} = insert(:pet, name: "abc")
%{id: id2} = insert(:pet, name: "a\\c")

for op <- [:like, :like_and, :like_or] do
flop = %Flop{filters: [%Filter{field: :name, op: op, value: "a\\c"}]}
assert [%Pet{id: ^id2}] = Flop.all(Pet, flop)
end
end

@tag :ilike
test "escapes \\ in ilike queries" do
%{id: _id1} = insert(:pet, name: "abc")
%{id: id2} = insert(:pet, name: "a\\c")

for op <- [:like, :ilike, :like_and, :like_or, :ilike_and, :ilike_or] do
for op <- [:ilike, :ilike_and, :ilike_or] do
flop = %Flop{filters: [%Filter{field: :name, op: op, value: "a\\c"}]}
assert [%Pet{id: ^id2}] = Flop.all(Pet, flop)
end
Expand All @@ -452,6 +485,7 @@ defmodule Flop.Adapters.Ecto.FlopTest do
end
end

@tag :ilike
property "applies ilike filter" do
check all pet_count <- integer(@pet_count_range),
pets = insert_list_and_sort(pet_count, :pet_with_owner),
Expand All @@ -470,6 +504,7 @@ defmodule Flop.Adapters.Ecto.FlopTest do
end
end

@tag :ilike
property "applies not ilike filter" do
check all pet_count <- integer(@pet_count_range),
pets = insert_list_and_sort(pet_count, :pet_with_owner),
Expand Down Expand Up @@ -533,6 +568,7 @@ defmodule Flop.Adapters.Ecto.FlopTest do
end
end

@tag :ilike
property "applies ilike_and filter" do

Check failure on line 572 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / Test Coverage

property filtering applies ilike_and filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 572 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 24 / Elixir 1.13

property filtering applies ilike_and filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 572 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 24 / Elixir 1.14

property filtering applies ilike_and filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 572 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 25 / Elixir 1.14

property filtering applies ilike_and filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 572 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 24 / Elixir 1.15

property filtering applies ilike_and filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 572 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 26 / Elixir 1.15

property filtering applies ilike_and filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 572 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 24 / Elixir 1.16

property filtering applies ilike_and filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 572 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 25 / Elixir 1.16

property filtering applies ilike_and filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 572 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 26 / Elixir 1.16

property filtering applies ilike_and filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 572 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 25 / Elixir 1.17

property filtering applies ilike_and filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 572 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 26 / Elixir 1.17

property filtering applies ilike_and filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 572 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 27 / Elixir 1.17

property filtering applies ilike_and filter (Flop.Adapters.Ecto.FlopTest)
check all pet_count <- integer(@pet_count_range),
pets = insert_list_and_sort(pet_count, :pet_with_owner),
Expand All @@ -552,6 +588,7 @@ defmodule Flop.Adapters.Ecto.FlopTest do
end
end

@tag :ilike
property "applies ilike_or filter" do

Check failure on line 592 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / Test Coverage

property filtering applies ilike_or filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 592 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 24 / Elixir 1.13

property filtering applies ilike_or filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 592 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 24 / Elixir 1.14

property filtering applies ilike_or filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 592 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 25 / Elixir 1.14

property filtering applies ilike_or filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 592 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 24 / Elixir 1.15

property filtering applies ilike_or filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 592 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 25 / Elixir 1.15

property filtering applies ilike_or filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 592 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 26 / Elixir 1.15

property filtering applies ilike_or filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 592 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 24 / Elixir 1.16

property filtering applies ilike_or filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 592 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 25 / Elixir 1.16

property filtering applies ilike_or filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 592 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 26 / Elixir 1.16

property filtering applies ilike_or filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 592 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 25 / Elixir 1.17

property filtering applies ilike_or filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 592 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 26 / Elixir 1.17

property filtering applies ilike_or filter (Flop.Adapters.Ecto.FlopTest)

Check failure on line 592 in test/adapters/ecto/cases/flop_test.exs

View workflow job for this annotation

GitHub Actions / OTP 27 / Elixir 1.17

property filtering applies ilike_or filter (Flop.Adapters.Ecto.FlopTest)
check all pet_count <- integer(@pet_count_range),
pets = insert_list_and_sort(pet_count, :pet_with_owner),
Expand Down
2 changes: 1 addition & 1 deletion test/adapters/ecto/sqlite/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ _ = Ecto.Adapters.SQLite3.storage_down(Flop.Repo.config())
:ok = Ecto.Migrator.up(Flop.Repo, 0, Flop.Repo.SQLite.Migration, log: false)

{:ok, _} = Application.ensure_all_started(:ex_machina)
ExUnit.start(exclude: [:composite_type, :prefix])
ExUnit.start(exclude: [:composite_type, :ilike, :prefix])

0 comments on commit 6f71cd9

Please sign in to comment.