@@ -2,6 +2,8 @@ defmodule AshPostgres.FilterTest do
22use AshPostgres.RepoCase , async: false
33alias AshPostgres.Test . { Api , Comment , Post }
44
5+ require Ash.Query
6+
57describe "with no filter applied" do
68test "with no data" do
79assert [ ] = Api . read! ( Post )
@@ -20,7 +22,7 @@ defmodule AshPostgres.FilterTest do
2022test "with no data" do
2123results =
2224Post
23- |> Ash.Query . filter ( title: "title" )
25+ |> Ash.Query . filter ( title == "title" )
2426|> Api . read! ( )
2527
2628assert [ ] = results
@@ -33,7 +35,7 @@ defmodule AshPostgres.FilterTest do
3335
3436results =
3537Post
36- |> Ash.Query . filter ( title: "title" )
38+ |> Ash.Query . filter ( title == "title" )
3739|> Api . read! ( )
3840
3941assert [ % Post { title: "title" } ] = results
@@ -46,7 +48,7 @@ defmodule AshPostgres.FilterTest do
4648
4749results =
4850Post
49- |> Ash.Query . filter ( title: "no_title" )
51+ |> Ash.Query . filter ( title == "no_title" )
5052|> Api . read! ( )
5153
5254assert [ ] = results
@@ -65,7 +67,7 @@ defmodule AshPostgres.FilterTest do
6567
6668results =
6769Post
68- |> Ash.Query . filter ( comments: [ title: "match" ] )
70+ |> Ash.Query . filter ( comments . title == "match" )
6971|> Api . read! ( )
7072
7173assert [ ] = results
@@ -84,7 +86,7 @@ defmodule AshPostgres.FilterTest do
8486
8587results =
8688Post
87- |> Ash.Query . filter ( comments: [ title: "match" ] )
89+ |> Ash.Query . filter ( comments . title == "match" )
8890|> Api . read! ( )
8991
9092assert [ % Post { title: "title" } ] = results
@@ -108,7 +110,7 @@ defmodule AshPostgres.FilterTest do
108110
109111results =
110112Post
111- |> Ash.Query . filter ( comments: [ title: "match" ] )
113+ |> Ash.Query . filter ( comments . title == "match" )
112114|> Api . read! ( )
113115
114116assert [ % Post { title: "title" } ] = results
@@ -119,7 +121,7 @@ defmodule AshPostgres.FilterTest do
119121test "with no data" do
120122results =
121123Post
122- |> Ash.Query . filter ( or: [ [ title: "title" ] , [ score: 1 ] ] )
124+ |> Ash.Query . filter ( title == "title" or score == 1 )
123125|> Api . read! ( )
124126
125127assert [ ] = results
@@ -132,7 +134,7 @@ defmodule AshPostgres.FilterTest do
132134
133135results =
134136Post
135- |> Ash.Query . filter ( or: [ [ title: "title" ] , [ score: 1 ] ] )
137+ |> Ash.Query . filter ( title == "title" or score == 1 )
136138|> Api . read! ( )
137139
138140assert [ ] = results
@@ -149,7 +151,7 @@ defmodule AshPostgres.FilterTest do
149151
150152results =
151153Post
152- |> Ash.Query . filter ( or: [ [ title: "title" ] , [ score: 1 ] ] )
154+ |> Ash.Query . filter ( title == "title" or score == 1 )
153155|> Api . read! ( )
154156|> Enum . sort_by ( & & 1 . score )
155157
@@ -167,7 +169,7 @@ defmodule AshPostgres.FilterTest do
167169
168170results =
169171Post
170- |> Ash.Query . filter ( or: [ [ title: "title" ] , [ score: 1 ] ] )
172+ |> Ash.Query . filter ( title == "title" or score == 1 )
171173|> Api . read! ( )
172174|> Enum . sort_by ( & & 1 . score )
173175
@@ -187,7 +189,7 @@ defmodule AshPostgres.FilterTest do
187189
188190results =
189191Post
190- |> Ash.Query . filter ( or: [ [ title: "match" ] , [ comments: [ title: "match" ] ] ] )
192+ |> Ash.Query . filter ( title == "match" or comments . title == "match" )
191193|> Api . read! ( )
192194
193195assert [ % Post { title: "doesn't match" } ] = results
@@ -206,7 +208,7 @@ defmodule AshPostgres.FilterTest do
206208
207209results =
208210Post
209- |> Ash.Query . filter ( or: [ [ title: "match" ] , [ comments: [ title: "match" ] ] ] )
211+ |> Ash.Query . filter ( title == "match" or comments . title == "match" )
210212|> Api . read! ( )
211213
212214assert [ % Post { title: "match" } ] = results
@@ -221,7 +223,7 @@ defmodule AshPostgres.FilterTest do
221223
222224results =
223225Post
224- |> Ash.Query . filter ( trigram_similarity: [ : title, "match" , [ greater_than: 0.9 ] ] )
226+ |> Ash.Query . filter ( trigram_similarity ( title , "match" , greater_than: 0.9 ) )
225227|> Api . read! ( )
226228
227229assert [ % Post { title: "match" } ] = results
@@ -234,7 +236,7 @@ defmodule AshPostgres.FilterTest do
234236
235237results =
236238Post
237- |> Ash.Query . filter ( trigram_similarity: [ : title, "match" , [ less_than: 0.1 ] ] )
239+ |> Ash.Query . filter ( trigram_similarity ( title , "match" , less_than: 0.1 ) )
238240|> Api . read! ( )
239241
240242assert [ ] = results