Can I use a field called size in a MongoEngine document?

313 views Asked by At

I have a document:

class Hamburger(Document):
    size = IntField(default=0, required=True)

which I can use fine

h = Hamburger()
h.size = 5
h.save()

until I try an update_one for example

Hamburger.objects().update_one(set__size=5)

which throws this exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/mongoengine/queryset/base.py", line 467, in update_one
    upsert=upsert, multi=False, write_concern=write_concern, **update)
  File "/usr/local/lib/python2.7/site-packages/mongoengine/queryset/base.py", line 430, in update
    update = transform.update(queryset._document, **update)
  File "/usr/local/lib/python2.7/site-packages/mongoengine/queryset/transform.py", line 207, in update
    field = cleaned_fields[-1]
IndexError: list index out of range

It is possible to have a Document with a field called size? Is there any way to achieve this?

0

There are 0 answers