-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add have any criteria #1042
Add have any criteria #1042
Changes from 3 commits
3396635
3066123
9fabef0
1326a8e
e5bcc71
16441de
9093463
98d594b
f291249
819cf52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,6 +154,11 @@ class Avram::Criteria(T, V) | |
add_clause(Avram::Where::In.new(column, values)) | ||
end | ||
|
||
def have_any?(values) : T | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the name better than my original idea; however, my only (very very small) concern is would this be confusing that it's a predicate method that doesn't return Bool or denote a nilable value? Maybe it's fine in this case, but I don't want people to confuse it with the if UserQuery.new.tags.have_any?(["featured"])
# would always return truethy
end
# would this be strange? lol
UserQuery.new.tags.have_any?(["featured"]).any? But if you don't think it'll be that big of an issue with some proper docs, then I'm cool with it as is 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uhmm... good point... especially the if branch I can see myself falling into it quite easily. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about just |
||
values = values.map { |value| V.adapter.to_db!(value) } | ||
add_clause(Avram::Where::Any.new(column, values)) | ||
end | ||
|
||
# :nodoc: | ||
def private_distinct_on : T | ||
rows.tap &.query.distinct_on(column) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops! Looks like this snuck in here 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤕 did the checkout from the wrong branch 😢