Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamline Usage with parse_params! and parse! #25

Closed
rcdilorenzo opened this issue Apr 20, 2016 · 1 comment
Closed

Streamline Usage with parse_params! and parse! #25

rcdilorenzo opened this issue Apr 20, 2016 · 1 comment
Milestone

Comments

@rcdilorenzo
Copy link
Owner

If an error happens with either of these calls, they will indicate in the Filtrex struct that the filter is empty:

%Filtrex{empty: true}

When this value is piped into Filtrex.query/2, it will by default not narrow the query but could be configurable to always return an empty set of values:

# default behavior:
Filters.query(YourApp.YourModel, %Filtrex{empty: true})
# => does not narrow query

# optional behavior
Filters.query(YourApp.YourModel, %Filtrex{empty: true}, allow_empty: false)
# => returns query that never matches (e.g. true == false or something similar)
@smpallen99
Copy link

Looks great. I like default to not narrow the query.

BTW, I tested the following..

import Ecto.Query

Product |> where(false) |> Repo.all
# []

@rcdilorenzo rcdilorenzo added this to the v0.3.0 milestone Jul 15, 2016
rcdilorenzo pushed a commit that referenced this issue Jul 20, 2016
Closes #25, built according to the spec described there. Thanks to @danielberkompas!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants