-
Notifications
You must be signed in to change notification settings - Fork 79
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
1 parent
67f6526
commit 99acc0f
Showing
7 changed files
with
105 additions
and
3 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
defmodule AshPostgres.Test.CustomExpressionTest do | ||
use AshPostgres.RepoCase, async: false | ||
|
||
test "unique constraint errors are properly caught" do | ||
Ash.create!(AshPostgres.Test.Profile, %{description: "foo"}) | ||
|
||
assert [_] = | ||
AshPostgres.Test.Profile | ||
|> Ash.Query.for_read(:by_indirectly_matching_description, %{term: "fop"}) | ||
|> Ash.read!() | ||
|
||
assert [_] = | ||
AshPostgres.Test.Profile | ||
|> Ash.Query.for_read(:by_directly_matching_description, %{term: "fop"}) | ||
|> Ash.read!() | ||
end | ||
end |
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
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,14 @@ | ||
defmodule AshPostgres.Expressions.TrigramWordSimilarity do | ||
@moduledoc false | ||
use Ash.CustomExpression, | ||
name: :trigram_word_similarity, | ||
arguments: [[:string, :string]], | ||
# setting to true does not seem to change the behaviour observed in this ticket | ||
predicate?: false | ||
|
||
def expression(data_layer, [left, right]) when data_layer in [AshPostgres.DataLayer] do | ||
{:ok, expr(fragment("word_similarity(?, ?)", ^left, ^right))} | ||
end | ||
|
||
def expression(_data_layer, _args), do: :unknown | ||
end |