Mongoengine embedded document query

I use flask-mongoengine.
query embedded documents

Topic.objects(userinfo__username="HGB")

in this way, there is no problem with querying embedded documents, and the results can be found.

I have an embedded document in the data model that uses a GenericEmbeddedDocumentField

the code is as follows:

    information = db.GenericEmbeddedDocumentField(required=True, choices=[AnimeInformation, ComicInformation])


    class AnimeInformation(db.EmbeddedDocument):
        episode = db.StringField()
    
        subtitle = db.StringField()
    
        is_finished = db.BooleanField(default=False)

        publish_date = db.DateTimeField(default=datetime.utcnow())
 
        updated_at = db.DateTimeField(default=datetime.utcnow())
    Topic.objects(information__episode="12")

in theory, it is correct to use the above sentence to query.
but will report an error.

error:

mongoengine.errors.InvalidQueryError
mongoengine.errors.InvalidQueryError: Cannot resolve subfield or operator episode on the field information

Traceback (most recent call last)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
raise value
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/Volumes/DATA One/dev/workspaces/BadLoli-Flask/api/topics.py", line 40, in index
information__episode="12"
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mongoengine/queryset/base.py", line 299, in first
result = queryset[0]
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mongoengine/queryset/base.py", line 197, in __getitem__
queryset._cursor[key],
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mongoengine/queryset/base.py", line 1547, in _cursor
self._cursor_obj = self._collection.find(self._query,
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mongoengine/queryset/base.py", line 1590, in _query
self._mongo_query = self._query_obj.to_query(self._document)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mongoengine/queryset/visitor.py", line 89, in to_query
query = query.accept(QueryCompilerVisitor(document))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mongoengine/queryset/visitor.py", line 155, in accept
return visitor.visit_query(self)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mongoengine/queryset/visitor.py", line 78, in visit_query
return transform.query(self.document, **query.query)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mongoengine/queryset/transform.py", line 63, in query
raise InvalidQueryError(e)
mongoengine.errors.InvalidQueryError: Cannot resolve subfield or operator episode on the field information

related documents http://docs.mongoengine.org/a.

confused

Apr.07,2021

found the problem mongoengine bug

I am using flask-mongoengine version 1.11 / mongoengine version 0.15

I upgraded mongoengine to 0.15.3. Just fine. All right, come on.

above there is no problem with the normal query results.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36456-2c02b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36456-2c02b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?