Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queryset.modify not support kwarg array_filters #2811

Open
ninochang opened this issue Apr 9, 2024 · 1 comment
Open

Queryset.modify not support kwarg array_filters #2811

ninochang opened this issue Apr 9, 2024 · 1 comment

Comments

@ninochang
Copy link

ninochang commented Apr 9, 2024

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.

idoshr pushed a commit to idoshr/mongoengine that referenced this issue Apr 18, 2024
add array filter to modify
@idoshr
Copy link
Contributor

idoshr commented Apr 18, 2024

Open fix PR
#2812

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

No branches or pull requests

2 participants