Fix using "$not" as top-level operator in output to MongoDb#1254
Fix using "$not" as top-level operator in output to MongoDb#1254
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders Open Preview |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 6d02dd7:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1254 +/- ##
==========================================
+ Coverage 80.73% 80.77% +0.03%
==========================================
Files 223 225 +2
Lines 12179 12213 +34
Branches 1544 1544
==========================================
+ Hits 9833 9865 +32
- Misses 1605 1610 +5
+ Partials 741 738 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
… is wrong 3) cond nor is wrong
// todo: $not $not
There was a problem hiding this comment.
Pull Request Overview
This PR fixes issues related to MongoDB output formatting. Key changes include the proper handling of the top‐level "$not" operator by switching to "$nor" in appropriate contexts and using a $dateFromString conversion with the correct date format.
- Updated test cases to use "$regexFind" for MongoDB.
- Revised widget configurations and export utilities for consistent MongoDB and SpEL formatting.
- Enhanced MongoDB query generation by escaping field names and adjusting negation handling.
Reviewed Changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/tests/specs/FuncAtLhs.test.ts | Updates regex operator usage to "$regexFind" |
| packages/examples/src/demo_switch/spel_concat.tsx | Migrates deprecated concatenation methods to new Spel utils |
| packages/examples/src/demo/index.tsx | Refactors state update with explicit tree and config assignment |
| packages/examples/src/demo/config/index.tsx | Adjusts MongoDB date conversion to use "$dateFromString" |
| packages/core/modules/export/mongoDb.js | Switches from "$not" to "$nor" where appropriate in MongoDB query |
| packages/core/modules/utils/* | Various refactors to utilize updated utils and method exports |
Comments suppressed due to low confidence (2)
packages/examples/src/demo/config/index.tsx:879
- Replacing dateVal.toDate() with a $dateFromString conversion ensures aggregation compatibility. Verify that the provided date format ('YYYY-MM-DD' and '%Y-%m-%d') meets MongoDB's parsing requirements.
if (dateVal.isValid()) {
packages/core/modules/export/mongoDb.js:237
- Using '$nor' as a replacement for top-level '$not' operator must be validated for all contexts. Confirm that wrapping the query with '$nor' in non-$filter scenarios behaves as expected in MongoDB.
resultQuery = { "$nor": [ resultQuery ] };
Fixes #1250
$notonly in allowed places in query, otherwide use{$nor: [a]}instead of{$not: a}exportPreserveGroupsfor mongo output$toDate).But it's supported only inside
$expr(so resulted query will be a bit longer)MongoUtils, JsonLogicUtils , SpelUtilstoUtils(extracted from core/modules/utils/export.js).MongoUtilsalso now ownsmongoFormatOp1andmongoFormatOp2. AddedmongoFieldEscapetoMongoUtilsto prevent using of$in field names that comed from configformat*functions only once at init (see using ofareConfigsSame) and only once on loading new data or clickingReload(see memoized func-components at examples/src/demo/blocks/output.tsx)mongoFormatOpfunction - fromfield, op, val, useExpr, ..tofield, op, val, not, useExpr, ..Handling
notinmongoFormatOpis a best placeRules of mongo regarding $not and $nor considered for this PR:
$exprinside$filter.condor inside$elemMatch$elemMatchcan't have$notand$exprinside BUT can have$nor$norcan't be inside$filter.condor$exprAlso rules for inside
$expr:$nincan't be used$regexwe should use$regexFind