Skip to content

Instantly share code, notes, and snippets.

@parkerl
Last active October 21, 2015 18:53
Show Gist options
  • Save parkerl/bc18066235e5c49f6a55 to your computer and use it in GitHub Desktop.
Save parkerl/bc18066235e5c49f6a55 to your computer and use it in GitHub Desktop.
error
defp escape(expr, type, params, binding, env) when is_list(expr) do
{parts, params} =
Enum.map_reduce(expr, %{}, fn {field, value}, acc ->
{value, params} = Builder.escape(value, {0, field}, acc, binding, env)
{{:==, [], [to_field(field), value]}, params}
end)
IO.inspect parts
expr = Enum.reduce parts, &{:and, [], [&1, &2]}
{expr, params}
end
q = where(FishLanded, [], [length: 10, weight: 1, fisherman_id: 1])
[{:==, [],
[{{:., [], [{:&, [], [0]}, :length]}, [], []},
{:%, [], [Ecto.Query.Tagged, {:%{}, [], [value: 10, type: {0, :length}]}]}]},
{:==, [],
[{{:., [], [{:&, [], [0]}, :weight]}, [], []},
{:%, [], [Ecto.Query.Tagged, {:%{}, [], [value: 1, type: {0, :weight}]}]}]},
{:==, [],
[{{:., [], [{:&, [], [0]}, :fisherman_id]}, [], []},
{:%, [],
[Ecto.Query.Tagged, {:%{}, [], [value: 1, type: {0, :fisherman_id}]}]}]}]
** (CompileError) iex:1: unhandled &0 outside of a capture
(stdlib) lists.erl:1353: :lists.mapfoldl/3
(stdlib) lists.erl:1353: :lists.mapfoldl/3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment