From 6c9345a624b7cde7ae841a22a5e47c467b722857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lafr=C3=A9choux?= Date: Sun, 19 Apr 2020 00:03:16 +0200 Subject: [PATCH] Fix collection/collection_name Meta confusion in tests/examples/README --- README.rst | 2 +- examples/flask/app.py | 2 +- examples/inheritance/app.py | 2 +- tests/frameworks/test_motor_asyncio.py | 8 -------- tests/frameworks/test_txmongo.py | 8 -------- 5 files changed, 3 insertions(+), 19 deletions(-) diff --git a/README.rst b/README.rst index 24df3441..ce124222 100644 --- a/README.rst +++ b/README.rst @@ -55,7 +55,7 @@ Quick example friends = fields.ListField(fields.ReferenceField("User")) class Meta: - collection = db.user + collection_name = "user" # Make sure that unique indexes are created User.ensure_indexes() diff --git a/examples/flask/app.py b/examples/flask/app.py index 25261028..a6a0bfc1 100644 --- a/examples/flask/app.py +++ b/examples/flask/app.py @@ -37,7 +37,7 @@ class User(Document): password = fields.StrField() # Don't store it in clear in real life ! class Meta: - collection = db.user + collection_name = "user" def populate_db(): diff --git a/examples/inheritance/app.py b/examples/inheritance/app.py index 00fc212f..68e7c5ec 100644 --- a/examples/inheritance/app.py +++ b/examples/inheritance/app.py @@ -13,7 +13,7 @@ class Vehicle(Document): model = fields.StrField(required=True) class Meta: - collection = db.vehicle + collection_name = "vehicle" allow_inheritance = True diff --git a/tests/frameworks/test_motor_asyncio.py b/tests/frameworks/test_motor_asyncio.py index 9d1dfdb1..9bf8ab48 100644 --- a/tests/frameworks/test_motor_asyncio.py +++ b/tests/frameworks/test_motor_asyncio.py @@ -477,7 +477,6 @@ class SimpleIndexDoc(Document): no_indexed = fields.IntField() class Meta: - collection = 'simple_index_doc' indexes = ['indexed'] await SimpleIndexDoc.collection.drop_indexes() @@ -512,7 +511,6 @@ class SimpleIndexDoc(Document): no_indexed = fields.IntField() class Meta: - collection = 'simple_index_doc' indexes = ['indexed'] await SimpleIndexDoc.collection.drop_indexes() @@ -547,9 +545,6 @@ class UniqueIndexDoc(Document): sparse_unique = fields.IntField(unique=True) required_unique = fields.IntField(unique=True, required=True) - class Meta: - collection = 'unique_index_doc' - await UniqueIndexDoc.collection.drop() await UniqueIndexDoc.collection.drop_indexes() @@ -599,7 +594,6 @@ class UniqueIndexCompoundDoc(Document): not_unique = fields.StrField() class Meta: - collection = 'unique_index_compound_doc' # Must define custom index to do that indexes = [{'key': ('compound1', 'compound2'), 'unique': True}] @@ -660,7 +654,6 @@ class UniqueIndexParentDoc(Document): unique = fields.IntField(unique=True) class Meta: - collection = 'unique_index_inheritance_doc' allow_inheritance = True @instance.register @@ -727,7 +720,6 @@ class InheritanceSearchParent(Document): pf = fields.IntField() class Meta: - collection = 'inheritance_search' allow_inheritance = True @instance.register diff --git a/tests/frameworks/test_txmongo.py b/tests/frameworks/test_txmongo.py index 0a04be50..5a652df6 100644 --- a/tests/frameworks/test_txmongo.py +++ b/tests/frameworks/test_txmongo.py @@ -408,7 +408,6 @@ class SimpleIndexDoc(Document): no_indexed = fields.IntField() class Meta: - collection = 'simple_index_doc' indexes = ['indexed'] yield SimpleIndexDoc.collection.drop_indexes() @@ -445,7 +444,6 @@ class SimpleIndexDoc(Document): no_indexed = fields.IntField() class Meta: - collection = 'simple_index_doc' indexes = ['indexed'] yield SimpleIndexDoc.collection.drop_indexes() @@ -482,9 +480,6 @@ class UniqueIndexDoc(Document): sparse_unique = fields.IntField(unique=True) required_unique = fields.IntField(unique=True, required=True) - class Meta: - collection = 'unique_index_doc' - yield UniqueIndexDoc.collection.drop() yield UniqueIndexDoc.collection.drop_indexes() @@ -537,7 +532,6 @@ class UniqueIndexCompoundDoc(Document): not_unique = fields.StrField() class Meta: - collection = 'unique_index_compound_doc' # Must define custom index to do that indexes = [{'key': ('compound1', 'compound2'), 'unique': True}] @@ -595,7 +589,6 @@ class UniqueIndexParentDoc(Document): unique = fields.IntField(unique=True) class Meta: - collection = 'unique_index_inheritance_doc' allow_inheritance = True @instance.register @@ -662,7 +655,6 @@ class InheritanceSearchParent(Document): pf = fields.IntField() class Meta: - collection = 'inheritance_search' allow_inheritance = True @instance.register