Skip to content

Instantly share code, notes, and snippets.

@moxley
Created July 15, 2016 23:14
Show Gist options
  • Save moxley/1e8c48a6dab31788b181facfc1f8851b to your computer and use it in GitHub Desktop.
Save moxley/1e8c48a6dab31788b181facfc1f8851b to your computer and use it in GitHub Desktop.
Build query dynamically
test "query with multiple WHEREs" do
query =
Easy.from({HomeAssessment, :ha})
|> Easy.where({:>=, [ha: :id], 1})
|> Easy.where({:<=, [ha: :id], 10})
|> Easy.build_query
assert inspect(query) == inspect(Q.from(ha in HomeAssessment, where: ha.id >= 1, where: ha.id <= 10))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment