Closed
Labels
api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.
Description
This leads to us saving string values as base64 encoded blobs... What's up with that? Is that on purpose?
Metadata
Metadata
Assignees
Labels
api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.
Activity
jgeewax commentedon Jun 9, 2016
Looks like we went from basestr (unicode + str) to just unicode... and str is treated as a blob ad90b7b ?
jgeewax commentedon Jun 9, 2016
Yea, looks like we did this on purpose... which seems kind of crazy that saving a regular string (ie,
{'name': 'Timmy'}) ends up as a b64-encoded blob.... @tseaver ?dhermes commentedon Jun 9, 2016
This has been true for almost 2 whole years. See the note
Also, blobs don't get base64 encoded, they are just displayed that way in the cloud console. They get stored as byte strings, which is exactly what they are.
jgeewax commentedon Jun 9, 2016
Hm. That's scary. Why is it that str in Python2 should convert to blob?
dhermes commentedon Jun 9, 2016
Not scary. In Python2,
str == bytes. There is no other way for us to detect that a user wantsbytesvs.unicode. Storing a bytestring is much more space-efficient than storing unicode, so it's certainly something we want to enable (and not all data is strings anyhow, so we always need to enable bytestrings)dhermes commentedon Jun 9, 2016
jgeewax commentedon Jun 9, 2016
OK, but doesn't this mean that I can't query for these results? Blobs aren't indexed are they?
It feels like if someone wants to store a blob, they should have to do something extra.... And if they store a
str(which yes, happens to be== bytes), we try to store it as astring_value...In other words, saving
{'name': 'Timmy'}to datastore as a Blob value seems completely backwards. If I wanted that as a blob, I should have to do something like{'name_blob': datastore.Blob('Timmy')}...jgeewax commentedon Jun 9, 2016
Right -- after conversation w @dhermes it's clear that I am wrong!
Here's the deal:
str == bytesblob_value, when it might have been better named asbytes_value)blob_value's are indexed, which means you can query as you always did without issueLong story short: use
u'Timmy'if you're clear on what the encoding should be (in this case,string_valuestores UTF-8 values).'Timmy'doesn't tell Datastore what the string encoding is, and therefore Datastore just treats it as some bytes...chore: move samples from python-docs-sample (#66)
chore: secret update (#1847)
fix: supplementary fix to env-based universe resolution (#1847)
docs: add data visualization samples for public doc (#1847)