From ef535364d257714fe37b1cb8e1e0ef278493cc18 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Fri, 17 Oct 2014 12:03:43 -0400 Subject: [PATCH 1/2] Update docstring for 'Connection.save_entity'. Indicate that upsert clears existing properties before applying those passed to the API. Fixes #167. --- gcloud/datastore/connection.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gcloud/datastore/connection.py b/gcloud/datastore/connection.py index cf52e5b51eaf..74b262675073 100644 --- a/gcloud/datastore/connection.py +++ b/gcloud/datastore/connection.py @@ -338,6 +338,10 @@ def commit(self, dataset_id, mutation_pb): def save_entity(self, dataset_id, key_pb, properties): """Save an entity to the Cloud Datastore with the provided properties. + .. note:: + Any existing properties for the entity will be cleared before + applying those passed in 'properties'. + :type dataset_id: string :param dataset_id: The dataset in which to save the entity. From 8e40313abf0bb1b0d07dd35baf134c7049b29ddd Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Fri, 17 Oct 2014 13:17:21 -0400 Subject: [PATCH 2/2] Update doctstrings for 'Entity.save' and 'Connection.save_entity'. Reinforce that previously-stored properties which don't have values set in the current entity instance will be removed. --- gcloud/datastore/connection.py | 5 +++-- gcloud/datastore/entity.py | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gcloud/datastore/connection.py b/gcloud/datastore/connection.py index 74b262675073..f11c528b2727 100644 --- a/gcloud/datastore/connection.py +++ b/gcloud/datastore/connection.py @@ -339,8 +339,9 @@ def save_entity(self, dataset_id, key_pb, properties): """Save an entity to the Cloud Datastore with the provided properties. .. note:: - Any existing properties for the entity will be cleared before - applying those passed in 'properties'. + Any existing properties for the entity identified by 'key_pb' + will be replaced by those passed in 'properties'; properties + not passed in 'properties' no longer be set for the entity. :type dataset_id: string :param dataset_id: The dataset in which to save the entity. diff --git a/gcloud/datastore/entity.py b/gcloud/datastore/entity.py index 59948084fa7a..bbce5012f444 100644 --- a/gcloud/datastore/entity.py +++ b/gcloud/datastore/entity.py @@ -187,6 +187,12 @@ def reload(self): def save(self): """Save the entity in the Cloud Datastore. + .. note:: + Any existing properties for the entity will be replaced by those + currently set on this instance. Already-stored properties which do + not correspond to keys set on this instance will be removed from + the datastore. + :rtype: :class:`gcloud.datastore.entity.Entity` :returns: The entity with a possibly updated Key. """