Skip to content

Commit

Permalink
fix filter
Browse files Browse the repository at this point in the history
  • Loading branch information
bluzky committed Oct 22, 2020
1 parent cde7a85 commit 5e8fca4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/filter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ defmodule Querie.Filter do
end

def filter(:is, {column, value}) do
filter(column, value)
dynamic([q], field(q, ^column) == ^value)
end

def filter(_op, {_column, nil}) do
Expand Down Expand Up @@ -120,6 +120,10 @@ defmodule Querie.Filter do
dynamic([q], field(q, ^column) >= ^lower and field(q, ^column) <= ^upper)
end

def filter(:has, {column, value}) do
dynamic([q], ^value in field(q, ^column))
end

def filter(:contains, {column, value}) do
dynamic([q], like(field(q, ^column), ^"%#{value}%"))
end
Expand Down
2 changes: 1 addition & 1 deletion lib/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ defmodule Querie.SchemaHelpers do
end

defmodule Querie.Parser do
@supported_ops ~w(lt gt ge le is ne in contains icontains between ibetween sort)
@supported_ops ~w(lt gt ge le is ne in contains icontains between ibetween sort has)

@doc """
Parse params and return
Expand Down

0 comments on commit 5e8fca4

Please sign in to comment.