Skip to content

Saving an abstract Document does not fail with a mongoengine.error #1152

@AWhetter

Description

@AWhetter
import mongoengine

mongoengine.connect()

class Project(mongoengine.Document):
    id = mongoengine.StringField()
    meta = {'abstract': True}

project = Project(id="TestProject")
project.save()

Running the above example fails with the following:

Traceback (most recent call last):
  File "test_project.py", line 10, in <module>
    project.save()
  File "C:\Python27\lib\site-packages\mongoengine\document.py", line 314, in save
    collection = self._get_collection()
  File "C:\Python27\lib\site-packages\mongoengine\document.py", line 207, in _get_collection
    cls._collection = db[collection_name]
  File "C:\Python27\lib\site-packages\pymongo\database.py", line 226, in __getitem__
    return Collection(self, name)
  File "C:\Python27\lib\site-packages\pymongo\collection.py", line 135, in __init__
    "of %s" % (string_type.__name__,))
TypeError: name must be an instance of basestring

I feel like it should fail with some mongoengine.error class rather than a TypeError.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions