Skip to content

Commit

Permalink
fix validation type coercion for comparison queries in issue #7
Browse files Browse the repository at this point in the history
  • Loading branch information
pablohirafuji authored and weixiyen committed Apr 23, 2018
1 parent 8c98f5d commit c066bad
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/triton/validate.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ defmodule Triton.Validate do
defp coerce(fragments, fields) when is_list(fragments), do: fragments |> Enum.map(fn fragment -> coerce_fragment(fragment, fields) end)
defp coerce(non_list, _), do: non_list

defp coerce_fragment({k, v}) when is_list(v), do: v |> Enum.map(fn {c, v} -> coerce_fragment({k, c, v}) end)
defp coerce_fragment({k, v}, fields) when is_list(v), do: {k, v |> Enum.map(fn {c, v} -> coerce_fragment({k, c, v}, fields) end)}
defp coerce_fragment({k, v}, fields), do: {k, coerced_value(v, fields[k][:type])}
defp coerce_fragment({k, c, v}, fields), do: {k, c, coerced_value(v, fields[k][:type])}
defp coerce_fragment({k, c, v}, fields), do: {c, coerced_value(v, fields[k][:type])}
defp coerce_fragment(x, _), do: x

defp coerced_value(value, _) when is_atom(value), do: value
Expand Down

0 comments on commit c066bad

Please sign in to comment.