Skip to content

Commit 6ba3c0e

Browse files
jwaltgrantcguardia
andcommitted
Fix #273 : Local Structured Property population via .populate(**kwargs) (#274)
* fixes #273 -Return the created model during validation (giving identical functionality to that of StructuredProperty) * Test for fix #273 * Fix test Co-authored-by: Carlos de la Guardia <cguardia@yahoo.com>
1 parent b0ea1cd commit 6ba3c0e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/google-cloud-ndb/google/cloud/ndb/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4099,7 +4099,7 @@ def _validate(self, value):
40994099
"""
41004100
if isinstance(value, dict):
41014101
# A dict is assumed to be the result of a _to_dict() call.
4102-
value = self._model_class(**value)
4102+
return self._model_class(**value)
41034103

41044104
if not isinstance(value, self._model_class):
41054105
raise exceptions.BadValueError(

packages/google-cloud-ndb/tests/unit/test_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3433,7 +3433,7 @@ class Simple(model.Model):
34333433

34343434
prop = model.LocalStructuredProperty(Simple, name="ent")
34353435
value = {}
3436-
assert prop._validate(value) is None
3436+
assert isinstance(prop._validate(value), Simple)
34373437

34383438
@staticmethod
34393439
def test__validate_dict_invalid():

0 commit comments

Comments
 (0)