Multiple similar filters can lose the existing filter
See original GitHub issueI think there is a bug in the new Morphia 2.2.3. I translated code from Morphia 1.x and the generated MongoDB queries seem to be mixed up when combining .exits() and .not() and that kind of combinations.
// OLD Morphia 1.x WORKED
q.or(q.criteria("disabled").doesNotExist(), q.criteria("disabled").hasThisOne(Boolean.FALSE));
// NEW Morphia 2.x DOES NOT WORK
q.filter(Filters.or(Filters.exists("disabled").not(), Filters.eq("disabled", Boolean.FALSE)));
);
// OLD Morphia 1.4 WORKED
// q.or(
// q.criteria("belongsToContentId").doesNotExist(),
// q.and(
// q.criteria("belongsToContentId").exists(),
// q.criteria("showAtGuideLevel").hasThisOne(Boolean.TRUE)
// )
// );
// NEW Morphia 2.x DOES NOT WORK
q.filter(
Filters.or(
Filters.exists("belongsToContentId").not(),
Filters.and(
Filters.exists("belongsToContentId"),
Filters.eq("showAtGuideLevel", Boolean.TRUE)
)
));
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Filter data in a range or table - Microsoft Support
Select Text Filters or Number Filters, and then select a comparison, like Between. Number Filters Between. Enter the filter criteria and select OK....
Read more >Excel 2013: Filtering Data - GCF Global
Filtering in Excel lets you temporarily hide unwanted data. Use filters in Excel to narrow down data in your Excel spreadsheet.
Read more >Apply Filters to Multiple Worksheets - Tableau Help
Filters that apply to all related data sources are marked with an icon. The filter is automatically created on any existing worksheets, and...
Read more >Excel FILTER function with formula examples - Ablebits
See how to filter in Excel dynamically with formulas. Examples to filter duplicates, cells containing certain text, with multiple criteria, ...
Read more >Excel Filters Training - Multiple Column Filters - Part 3 of 3
You will learn about the rules Excel uses to apply filters with AND logic. I also explain how to filter multiple columns with...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You should use
find()
instead: https://morphia.dev/morphia/2.2/javadoc/dev/morphia/Datastore.html#createQuery(java.lang.Class)I tried today if the problem is fixed with morphia 2.2.5, but there still seems to be a problem. STEP 1:
STEP 2:
BUG: The filter of status from before is gone?