Merge pull request #1570 from erdenezul/remove_save_embedded
EmbeddedDocument should not have save method #1552
This commit is contained in:
		| @@ -23,6 +23,7 @@ Development | |||||||
|     - Calling `connect` 2 times with the same alias and different parameter will raise an error (should call `disconnect` first). |     - Calling `connect` 2 times with the same alias and different parameter will raise an error (should call `disconnect` first). | ||||||
|     - `disconnect` now clears `mongoengine.connection._connection_settings`. |     - `disconnect` now clears `mongoengine.connection._connection_settings`. | ||||||
|     - `disconnect` now clears the cached attribute `Document._collection`. |     - `disconnect` now clears the cached attribute `Document._collection`. | ||||||
|  | - BREAKING CHANGE: `EmbeddedDocument.save` & `.reload` is no longier exist #1552 | ||||||
| - (Fill this out as you fix issues and develop your features). | - (Fill this out as you fix issues and develop your features). | ||||||
|  |  | ||||||
| Changes in 0.17.0 | Changes in 0.17.0 | ||||||
|   | |||||||
| @@ -90,18 +90,6 @@ class EmbeddedDocument(six.with_metaclass(DocumentMetaclass, BaseDocument)): | |||||||
|  |  | ||||||
|         return data |         return data | ||||||
|  |  | ||||||
|     def save(self, *args, **kwargs): |  | ||||||
|         warnings.warn("EmbeddedDocument.save is deprecated and will be removed in a next version of mongoengine." |  | ||||||
|                       "Use the parent document's .save() or ._instance.save()", |  | ||||||
|                       DeprecationWarning, stacklevel=2) |  | ||||||
|         self._instance.save(*args, **kwargs) |  | ||||||
|  |  | ||||||
|     def reload(self, *args, **kwargs): |  | ||||||
|         warnings.warn("EmbeddedDocument.reload is deprecated and will be removed in a next version of mongoengine." |  | ||||||
|                       "Use the parent document's .reload() or ._instance.reload()", |  | ||||||
|                       DeprecationWarning, stacklevel=2) |  | ||||||
|         self._instance.reload(*args, **kwargs) |  | ||||||
|  |  | ||||||
|  |  | ||||||
| class Document(six.with_metaclass(TopLevelDocumentMetaclass, BaseDocument)): | class Document(six.with_metaclass(TopLevelDocumentMetaclass, BaseDocument)): | ||||||
|     """The base class used for defining the structure and properties of |     """The base class used for defining the structure and properties of | ||||||
|   | |||||||
| @@ -3189,24 +3189,6 @@ class InstanceTest(MongoDBTestCase): | |||||||
|             "UNDEFINED", |             "UNDEFINED", | ||||||
|             system.nodes["node"].parameters["param"].macros["test"].value) |             system.nodes["node"].parameters["param"].macros["test"].value) | ||||||
|  |  | ||||||
|     def test_embedded_document_save_reload_warning(self): |  | ||||||
|         """Relates to #1570""" |  | ||||||
|         class Embedded(EmbeddedDocument): |  | ||||||
|             pass |  | ||||||
|  |  | ||||||
|         class Doc(Document): |  | ||||||
|             emb = EmbeddedDocumentField(Embedded) |  | ||||||
|  |  | ||||||
|         doc = Doc(emb=Embedded()).save() |  | ||||||
|         doc.emb.save()  # Make sure its still working |  | ||||||
|         with warnings.catch_warnings(): |  | ||||||
|             warnings.simplefilter("error", DeprecationWarning) |  | ||||||
|             with self.assertRaises(DeprecationWarning): |  | ||||||
|                 doc.emb.save() |  | ||||||
|  |  | ||||||
|             with self.assertRaises(DeprecationWarning): |  | ||||||
|                 doc.emb.reload() |  | ||||||
|  |  | ||||||
|     def test_embedded_document_equality(self): |     def test_embedded_document_equality(self): | ||||||
|         class Test(Document): |         class Test(Document): | ||||||
|             field = StringField(required=True) |             field = StringField(required=True) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user