Skip to content

Condition to Bson fix#14

Open
WesleyEdwards wants to merge 3 commits into
mainfrom
we/bson-list-all-embedded-list-fix
Open

Condition to Bson fix#14
WesleyEdwards wants to merge 3 commits into
mainfrom
we/bson-list-all-embedded-list-fix

Conversation

@WesleyEdwards

@WesleyEdwards WesleyEdwards commented May 8, 2026

Copy link
Copy Markdown
Contributor

The ListAllElements was having issues with a list of an object.
Added a test to account for this case and changes to ListAllElements and Not Bson converters

For mongo filters, $nor is a "Top-level logical query operator", meaning that it cannot be nested directly under a field or an $elemMatch.

Previously, Condition.Not always used $nor.
This is invalid, because $elemMatch expects a field condition instead of a top-level query operator.

{
  list: {
    $not: {
      $elemMatch: {
        $nor: [
          { $lt: 4 }
        ]
      }
    }
  }
}

But this is valid:

{
  list: {
    $not: {
      $elemMatch: {
        $not: {
           $lt: 4
            }
        ]
      }
    }
  }
}

But $nor is still necessary when wrapping field conditions and other logical operators (like 'and' and 'or')
i.e. { "$nor": [ { "subField": 1 } ] })

So I changed the 'Not' Condition -> Bson to account for that. I also made it so ListAllElements uses the Not conversion logic because it would run into the same problem

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

Successfully merging this pull request may close these issues.

1 participant