MongoEngine/mongoengine

Error on filtering on list of floats with empty list

razbamnolker opened this issue · 2 comments

The following error message has been raised:
WhatsApp Image 2024-04-24 at 18 34 32

When filtering the following :
Collection.objects(float_list__gt=[]) where float_list: mongo_db.ListField(field=mongo_db.FloatField())

Created a PR for that issue : #2813

Issue is broader than just this, in fact MongoEngine currently doesn't allow to use gt operator with a list (empty or not). Although a bit confusing, MongoDB allows it

Given a collection with following documents

[{'_id': ObjectId('66bf8f26b5d653b25496d539'), 'ages': [1.0, 2.0]},
 {'_id': ObjectId('66bfbcf20b7bba1c9071c6c1'), 'ages': []}]

Querying works like this (attaching this as results may not be what you expect)
image

Thus, querying on __gt = [ ] will actually match any non-empty list, is it what you are trying to achieve?