Created
October 19, 2016 14:09
-
-
Save bencrouse/e8af3b4a762a339d059fcfb7716a430e to your computer and use it in GitHub Desktop.
Mongoid Criteria merging fixes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_key == '$in' ? new_val & old_val : old_val | new_val |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fairly defensive fix | |
if _key == '$in' | |
new_val & old_val | |
elsif old_val.respond_to?(:|) | |
old_val | new_val | |
else | |
new_val | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# maybe riskier fix | |
if old_val == new_val | |
new_val | |
elsif _key == '$in' | |
new_val & old_val | |
else | |
old_val | new_val | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment