MongoEngine / MongoEngine/mongoengine

slice on dict field containing list does'nt work

Open
#2,635 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.3k
Forks
1.2k
Avg merge
4h 41m
Merged PRs (30d)
11

Description

pymongo: 3.12.0
mongoengine: 0.23.1

I have a document:

class Logs(Document):
    reference_id = StringField(default=None)
    data = DictField(default=None)

In data field, i have a list failed_stories. This can have hundreds of elements and I want to perform pagination on it. So, i write this query as:

start_idx = 0
page_size = 10
reference_id = 'asdfg345678'
Logs.objects(reference_id=reference_id).fields(slice__data__failed_stories=[start_idx, page_size])

With this, i get one document in which all field are None except the dociment id (_id).

The following query results in document with correct data in document fields.
Logs.objects(reference_id=reference_id).get()

Is there any issue with the way I am writing this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with MongoEngine 0.23.1 and PyMongo 3.12.0 using the Logs document and the fields(slice__data__failed_stories=[0, 10]) query. Compare its result with Logs.objects(reference_id=reference_id).get(), then trace the slice projection entry point and add or run a regression test. Done means pagination returns the requested list elements without turning the other document fields into None.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, python
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.