_get_changed_fields fix for embedded documents with id field.
removed commented out piece of code added author and record to changelog
This commit is contained in:
		
							
								
								
									
										1
									
								
								AUTHORS
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								AUTHORS
									
									
									
									
									
								
							| @@ -219,3 +219,4 @@ that much better: | |||||||
|  * Jimmy Shen (https://github.com/jimmyshen) |  * Jimmy Shen (https://github.com/jimmyshen) | ||||||
|  * J. Fernando Sánchez (https://github.com/balkian) |  * J. Fernando Sánchez (https://github.com/balkian) | ||||||
|  * Michael Chase (https://github.com/rxsegrxup) |  * Michael Chase (https://github.com/rxsegrxup) | ||||||
|  |  * Eremeev Danil (https://github.com/elephanter) | ||||||
|   | |||||||
| @@ -85,6 +85,7 @@ Changes in 0.9.0 | |||||||
| - Fixed a few instances where reverse_delete_rule was written as reverse_delete_rules. #791 | - Fixed a few instances where reverse_delete_rule was written as reverse_delete_rules. #791 | ||||||
| - Make `in_bulk()` respect `no_dereference()` #775 | - Make `in_bulk()` respect `no_dereference()` #775 | ||||||
| - Handle None from model __str__; Fixes #753 #754 | - Handle None from model __str__; Fixes #753 #754 | ||||||
|  | - _get_changed_fields fix for embedded documents with id field. #925 | ||||||
|  |  | ||||||
| Changes in 0.8.7 | Changes in 0.8.7 | ||||||
| ================ | ================ | ||||||
|   | |||||||
| @@ -553,7 +553,6 @@ class BaseDocument(object): | |||||||
|             if hasattr(data, 'id'): |             if hasattr(data, 'id'): | ||||||
|                 if data.id in inspected: |                 if data.id in inspected: | ||||||
|                     continue |                     continue | ||||||
|                 inspected.add(data.id) |  | ||||||
|             if isinstance(field, ReferenceField): |             if isinstance(field, ReferenceField): | ||||||
|                 continue |                 continue | ||||||
|             elif (isinstance(data, (EmbeddedDocument, DynamicEmbeddedDocument)) |             elif (isinstance(data, (EmbeddedDocument, DynamicEmbeddedDocument)) | ||||||
|   | |||||||
| @@ -93,6 +93,7 @@ class DeltaTest(unittest.TestCase): | |||||||
|     def delta_recursive(self, DocClass, EmbeddedClass): |     def delta_recursive(self, DocClass, EmbeddedClass): | ||||||
|  |  | ||||||
|         class Embedded(EmbeddedClass): |         class Embedded(EmbeddedClass): | ||||||
|  |             id = StringField() | ||||||
|             string_field = StringField() |             string_field = StringField() | ||||||
|             int_field = IntField() |             int_field = IntField() | ||||||
|             dict_field = DictField() |             dict_field = DictField() | ||||||
| @@ -114,6 +115,7 @@ class DeltaTest(unittest.TestCase): | |||||||
|         self.assertEqual(doc._delta(), ({}, {})) |         self.assertEqual(doc._delta(), ({}, {})) | ||||||
|  |  | ||||||
|         embedded_1 = Embedded() |         embedded_1 = Embedded() | ||||||
|  |         embedded_1.id = "010101" | ||||||
|         embedded_1.string_field = 'hello' |         embedded_1.string_field = 'hello' | ||||||
|         embedded_1.int_field = 1 |         embedded_1.int_field = 1 | ||||||
|         embedded_1.dict_field = {'hello': 'world'} |         embedded_1.dict_field = {'hello': 'world'} | ||||||
| @@ -123,6 +125,7 @@ class DeltaTest(unittest.TestCase): | |||||||
|         self.assertEqual(doc._get_changed_fields(), ['embedded_field']) |         self.assertEqual(doc._get_changed_fields(), ['embedded_field']) | ||||||
|  |  | ||||||
|         embedded_delta = { |         embedded_delta = { | ||||||
|  |             'id': "010101", | ||||||
|             'string_field': 'hello', |             'string_field': 'hello', | ||||||
|             'int_field': 1, |             'int_field': 1, | ||||||
|             'dict_field': {'hello': 'world'}, |             'dict_field': {'hello': 'world'}, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user