mongoengine icon indicating copy to clipboard operation
mongoengine copied to clipboard

`Queryset.modify` not support kwarg `array_filters`

Open ninochang opened this issue 1 year ago • 1 comments

Starts from 0.28.0 update, and update_one starts to support kwarg array_filters which inline with https://www.mongodb.com/docs/manual/reference/operator/update/positional-filtered/.

Base on mongodb doc link above, Queryset.modify should also support array_filters, the underlying pymongo function also supports it.

Current behavior mongoengine: 0.28.2

User.objects.filter(id='uid').only('id', 'items').modify(
    __raw__={'$set': {'items.$[item].done': True}},
    array_filters=[{
        '$and': [
            {'item.id': 'qqq'},
        ],
    }],
)

#  InvalidQueryError: Cannot resolve field "array_filters"

The solution should be similar to This PR, handle array_filters inside modify function.

ninochang avatar Apr 09 '24 06:04 ninochang

Open fix PR https://github.com/MongoEngine/mongoengine/pull/2812

idoshr avatar Apr 18 '24 08:04 idoshr

Got merged on master

bagerard avatar Aug 26 '24 20:08 bagerard