GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Support 'blob_value' / 'blob_key_value' in datastore protobufs · Issue #233 · googleapis/google-cloud-python

Support 'blob_value' / 'blob_key_value' in datastore protobufs #233

New issue
Copy link
New issue
Copy link
Closed
Closed
Support 'blob_value' / 'blob_key_value' in datastore protobufs#233
Copy link
Assignees
tseaver
Labels
api: datastoreIssues related to the Datastore API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Description

@tseaver
tseaver
opened on Oct 9, 2014
Issue body actions

In addition to the scalar types we already support, there are the following value types we don't yet
support:

  • 'entity_value' (PR Support entity protobufs #232)
  • 'list_value' (issue Support list values in entities #223)
  • 'blob_value' (see https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/6073e01540264db58ee50c30a1e9f006677eb794/proto/datastore_v1.proto#L115)
  • 'blob_key_value' (see https://github.com/GoogleCloudPlatform/google-cloud-datastore/blob/6073e01540264db58ee50c30a1e9f006677eb794/proto/datastore_v1.proto#L111)

Activity

Next
  1. tseaver
    added
    api: datastoreIssues related to the Datastore API.
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    on Oct 9, 2014
  2. dhermes commented on Oct 9, 2014

    @dhermes
    dhermes
    on Oct 9, 2014
    Contributor
    More actions

    This is something we could check in an automated fashion:

    >>> from gcloud.datastore import datastore_v1_pb2 as pb2
    >>> for attr in dir(pb2.Value):
    ...     if attr[0] == attr[0].lower() and attr[0] != '_':
    ...         print attr
    ... 
    blob_key_value
    blob_value
    boolean_value
    double_value
    entity_value
    indexed
    integer_value
    key_value
    list_value
    meaning
    string_value
    timestamp_microseconds_value

    or

    >>> for key in sorted(pb2._VALUE.fields_by_name.keys()):
    ...     print key
    ... 
    blob_key_value
    blob_value
    boolean_value
    double_value
    entity_value
    indexed
    integer_value
    key_value
    list_value
    meaning
    string_value
    timestamp_microseconds_value
  3. tseaver commented on Oct 16, 2014

    @tseaver
    tseaver
    on Oct 16, 2014
    ContributorAuthor
    More actions

    Note that handling 'blob_value' values will require us to think harder about handling "bytes" (marshalled via 'blob_value') vs. "text" (marshalled via 'string_value'). At the moment, we rather sloppily conflate handling both Python2 'str' and 'unicode' via 'string_value'.

  4. silvolu
    added this to the This milestone has been deleted milestone on Oct 17, 2014
  5. silvolu commented on Oct 18, 2014

    @silvolu
    silvolu
    on Oct 18, 2014
    Contributor
    More actions

    @tseaver as you mentioned in #157, we should raise exceptions after the value types coverage is complete.

  6. silvolu commented on Oct 18, 2014

    @silvolu
    silvolu
    on Oct 18, 2014
    Contributor
    More actions

    I think we're missing value types in _get_protobuf_attribute_and_value(https://github.com/GoogleCloudPlatform/gcloud-python/blob/master/gcloud/datastore/_helpers.py#L17) as well.

  7. tseaver commented on Oct 18, 2014

    @tseaver
    tseaver
    on Oct 18, 2014
    ContributorAuthor
    More actions

    That will get tricksy:

    • 'blob_value' should map to 'str' / 'bytes' in Python2, and 'bytes' in Python3
    • 'string_value' should map to 'unicode' in Python2, and 'str' in Python3

    Right now:

    >>> from gcloud.datastore._helpers import _get_protobuf_attribute_and_value
    >>> _get_protobuf_attribute_and_value(b'foo')
    ('string_value', 'foo')
    >>> _get_protobuf_attribute_and_value(u'foo')
    ('string_value', u'foo')
    >>> _get_protobuf_attribute_and_value('foo')
    ('string_value', 'foo')
    

    which can't be right, long-term. It should be (under Python2):

    >>> _get_protobuf_attribute_and_value(b'foo')
    ('blob_value', 'foo')
    >>> _get_protobuf_attribute_and_value(u'foo')
    ('string_value', u'foo')
    >>> _get_protobuf_attribute_and_value('foo')
    ('blob_value', 'foo')
    

    and under Py3k:

    >>> _get_protobuf_attribute_and_value(b'foo')
    ('blob_value', 'foo')
    >>> _get_protobuf_attribute_and_value('foo')
    ('string_value', u'foo')
    >>> _get_protobuf_attribute_and_value('foo')
    ('string_value', 'foo')
    

    OTOH, '_get_value_from_value_pb' looks right:

    >>> from gcloud.datastore.datastore_v1_pb2 import Value
    >>> v = Value()
    >>> v.string_value = 'abc'
    >>> from gcloud.datastore._helpers import _get_value_from_value_pb
    >>> _get_value_from_value_pb(v)
    u'abc'
    

    We'd like for the following to work:

    >>> vb = Value()
    >>> vb.blob_value = b'abc'
    >>> _get_value_from_value_pb(vb)
    'abc'
    

    but it currently returns None.

  8. tseaver
    self-assigned this
    on Oct 18, 2014
  9. tseaver commented on Oct 18, 2014

    @tseaver
    tseaver
    on Oct 18, 2014
    ContributorAuthor
    More actions

    Changing to use 'blob_value' for bytes / native str in Python2 will be the one which confounds users expectations.

  10. dhermes commented on Oct 18, 2014

    @dhermes
    dhermes
    on Oct 18, 2014
    Contributor
    More actions

    Indeed. I wonder if people have done things to deal with this in other libraries. Potentially encoding/decoding to ASCII or something similar?

  11. silvolu commented on Oct 18, 2014

    @silvolu
    silvolu
    on Oct 18, 2014
    Contributor
    More actions

    @tseaver Saw your fix for blob_value in #233.
    If we add list_value to _set_protobuf_value, then we should support all value types when writing entities.

  12. tseaver commented on Oct 18, 2014

    @tseaver
    tseaver
    on Oct 18, 2014
    ContributorAuthor
    More actions

    @silvolu see #265.

  13. tseaver
    added a commit that references this issue on Oct 19, 2014

    Merge pull request #263 from tseaver/233-support_blob_value

    99e4d53
  14. tseaver commented on Oct 20, 2014

    @tseaver
    tseaver
    on Oct 20, 2014
    ContributorAuthor
    More actions

    #263 adds 'blob_value' support. @silvolu says we can skip 'blob_key_value'.

  15. 66 remaining items

  16. parthea
    added 7 commits that reference this issue on Nov 24, 2025

    build(deps): bump requests from 2.28.1 to 2.31.0 in /synthtool/gcp/te…

    dba08b3

    feat: add support for Python 3.10 (#233)

    e41f383

    chore: release 2.2.0 (#238)

    c4db9cf

    build: update actions/upload-artifact and actions/download-artifact (#…

    db594fc

    feat: Add support for Python 3.12 (#233)

    67be61c

    chore: update copyright year to 2022 (#233)

    831f298

    Release v1.3.0 (#233)

    222b2f3
  17. parthea
    added 2 commits that reference this issue on Mar 2, 2026

    samples: fix flaky tests (#233)

    4b49b6c

    feat: Add Python 3.13 trove classifier (#233)

    dccfc62
  18. parthea
    added 5 commits that reference this issue on Mar 9, 2026

    Update README.rst (#233)

    8525692

    chore(py_library): add some excludes in docs/conf.py (#233)

    3fad9f0

    fix: fix execute insert for homogeneous statement (#233)

    1ba289c

    fix(db_api): revert Mutations API usage (#285)

    8bf8623

    chore: use templated renovate.json (#233)

    8eeb323
  19. ohmayr
    added a commit that references this issue on Mar 31, 2026

    feat: Add Python 3.13 trove classifier (#233)

    17c060c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @tseaver
    tseaver

Labels

api: datastoreIssues related to the Datastore API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.