mongoengine icon indicating copy to clipboard operation
mongoengine copied to clipboard

Error on filtering on list of floats with empty list

Open razbamnolker opened this issue 1 year ago • 1 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())

razbamnolker avatar Apr 24 '24 15:04 razbamnolker

Created a PR for that issue : #2813

razbamnolker avatar Apr 24 '24 15:04 razbamnolker

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?

bagerard avatar Aug 16 '24 21:08 bagerard