From b7ec4375d2e1da72a2fedb3d57541816bd6b7ab1 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Mon, 3 Nov 2014 16:11:25 -0500 Subject: [PATCH 1/2] Document further how 'text' vs. 'bytes' values are stored. Note how the two differ in Python2 vs. Python3. Fixes #266. --- gcloud/datastore/entity.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gcloud/datastore/entity.py b/gcloud/datastore/entity.py index 0d75a5c9b413..b05e841d3499 100644 --- a/gcloud/datastore/entity.py +++ b/gcloud/datastore/entity.py @@ -68,6 +68,16 @@ class Entity(dict): >>> dict(entity) {'age': 20, 'name': 'JJ'} + .. note:: + + When saving an entity to the backend, values which are "text" + ('unicode' in Python2, 'str' in Python3) will be saved using + the 'text_value' field, after being encoded to UTF-8. When + retrieved from the back-end, such values will be decoded to "text" + again. Values which are "bytes" ('str' in Python2, 'bytes' in + Python3), will be saved using the 'bytes_value' field, without + any decoding / encoding step. + """ def __init__(self, dataset=None, kind=None): From 95336d9956a140d908bb8c2319e6e985b047e8dd Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Mon, 3 Nov 2014 16:52:42 -0500 Subject: [PATCH 2/2] Think-o: 'bytes_value' -> 'blob_value'. Incorporates feedback from @dhermes. --- gcloud/datastore/entity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcloud/datastore/entity.py b/gcloud/datastore/entity.py index b05e841d3499..cf325d8b0fba 100644 --- a/gcloud/datastore/entity.py +++ b/gcloud/datastore/entity.py @@ -75,7 +75,7 @@ class Entity(dict): the 'text_value' field, after being encoded to UTF-8. When retrieved from the back-end, such values will be decoded to "text" again. Values which are "bytes" ('str' in Python2, 'bytes' in - Python3), will be saved using the 'bytes_value' field, without + Python3), will be saved using the 'blob_value' field, without any decoding / encoding step. """