Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity indexed=False not preserved in helpers.entity_from_protobuf #513

Closed
dhermes opened this issue Jan 8, 2015 · 0 comments · Fixed by #541
Closed

Entity indexed=False not preserved in helpers.entity_from_protobuf #513

dhermes opened this issue Jan 8, 2015 · 0 comments · Fixed by #541
Assignees
Labels
api: datastore Issues related to the Datastore API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@dhermes
Copy link
Contributor

dhermes commented Jan 8, 2015

In entity_from_protobuf a key is created and the values are added via

    for property_pb in pb.property:
        value = _get_value_from_property_pb(property_pb)
        entity[property_pb.name] = value

However, property_pb.value.indexed is ignored and entity has the default empty tuple for exclude_from_indexes.


To see this, first save with exclude_from_indexes non-empty and inspect the protobuf values:

>>> from gcloud import datastore
>>> from gcloud.datastore.entity import Entity
>>> from gcloud.datastore.key import Key
>>>
>>> datastore.set_default_connection()
>>> datastore.set_default_dataset_id('foo')
>>>
>>> e = Entity(key=Key('Foo', 1), exclude_from_indexes=('foo', 'bar'))
>>> e.update({
...     'foo': 10,
...     'bar': 11,
...     'baz': 12,
... })
>>> e.save()
>>>
>>> entity_pb, = datastore.get_connection().lookup(
...         dataset_id=e.key.dataset_id,
...         key_pbs=[e.key.to_protobuf()],
... )
>>> for p in entity_pb.property:
...     print p.value.indexed
...
True
False
False

then use the key to get (which calls get_entities -> entity_from_protobuf), save the newly created (supposedly identical) Entity. After saving, check the same protobuf values:

>>> e_retrieved = e.key.get()
>>> e_retrieved.save()
>>>
>>> entity_pb, = datastore.get_connection().lookup(
...         dataset_id=e_retrieved.key.dataset_id,
...         key_pbs=[e_retrieved.key.to_protobuf()],
... )
>>> for p in entity_pb.property:
...     print p.value.indexed
...
True
True
True
@dhermes dhermes added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. api: datastore Issues related to the Datastore API. labels Jan 8, 2015
@dhermes dhermes self-assigned this Jan 14, 2015
dhermes added a commit to dhermes/google-cloud-python that referenced this issue Jan 14, 2015
dhermes added a commit to dhermes/google-cloud-python that referenced this issue Jan 15, 2015
dhermes added a commit to dhermes/google-cloud-python that referenced this issue Jan 15, 2015
@jgeewax jgeewax modified the milestone: Datastore Stable Jan 30, 2015
atulep pushed a commit that referenced this issue Apr 18, 2023
* test: use mock from unittest

* Use `from unittest import mock`
parthea pushed a commit that referenced this issue Sep 22, 2023
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this issue Sep 22, 2023
Source-Link: https://github.com/googleapis/synthtool/commit/eaef28efd179e6eeb9f4e9bf697530d074a6f3b9
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:f8ca7655fa8a449cadcabcbce4054f593dcbae7aeeab34aa3fcc8b5cf7a93c9e
parthea pushed a commit that referenced this issue Oct 21, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [google-cloud-asset](https://github.com/googleapis/python-asset) | `==3.14.1` -> `==3.14.2` | [![age](https://badges.renovateapi.com/packages/pypi/google-cloud-asset/3.14.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/google-cloud-asset/3.14.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/google-cloud-asset/3.14.2/compatibility-slim/3.14.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/google-cloud-asset/3.14.2/confidence-slim/3.14.1)](https://docs.renovatebot.com/merge-confidence/) |
| [google-cloud-bigquery](https://github.com/googleapis/python-bigquery) | `==3.3.3` -> `==3.3.5` | [![age](https://badges.renovateapi.com/packages/pypi/google-cloud-bigquery/3.3.5/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/google-cloud-bigquery/3.3.5/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/google-cloud-bigquery/3.3.5/compatibility-slim/3.3.3)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/google-cloud-bigquery/3.3.5/confidence-slim/3.3.3)](https://docs.renovatebot.com/merge-confidence/) |
| [google-cloud-pubsub](https://github.com/googleapis/python-pubsub) | `==2.13.7` -> `==2.13.9` | [![age](https://badges.renovateapi.com/packages/pypi/google-cloud-pubsub/2.13.9/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/google-cloud-pubsub/2.13.9/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/google-cloud-pubsub/2.13.9/compatibility-slim/2.13.7)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/google-cloud-pubsub/2.13.9/confidence-slim/2.13.7)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>googleapis/python-asset</summary>

### [`v3.14.2`](https://github.com/googleapis/python-asset/releases/tag/v3.14.2)

[Compare Source](https://github.com/googleapis/python-asset/compare/v3.14.1...v3.14.2)

## 🤖 I have created a release *beep* *boop*

#### [3.14.2](https://github.com/googleapis/python-asset/compare/v3.14.1...v3.14.2) (2022-10-10)

##### Bug Fixes

-   **deps:** Allow protobuf 3.19.5 ([#&#8203;508](https://github.com/googleapis/python-asset/issues/508)) ([818abbb](https://github.com/googleapis/python-asset/commit/818abbbcbb829a726d18ba1e7e7e03f997d4256a))

</details>

<details>
<summary>googleapis/python-bigquery</summary>

### [`v3.3.5`](https://github.com/googleapis/python-bigquery/releases/tag/v3.3.5)

[Compare Source](https://github.com/googleapis/python-bigquery/compare/v3.3.3...v3.3.5)

##### Bug Fixes

-   **deps:** Allow protobuf 3.19.5 ([#&#8203;1379](https://github.com/googleapis/python-bigquery/issues/1379)) ([3e4a074](https://github.com/googleapis/python-bigquery/commit/3e4a074a981eb2920c5f9a711c253565d4844858))

</details>

<details>
<summary>googleapis/python-pubsub</summary>

### [`v2.13.9`](https://github.com/googleapis/python-pubsub/releases/tag/v2.13.9)

[Compare Source](https://github.com/googleapis/python-pubsub/compare/v2.13.7...v2.13.9)

##### Bug Fixes

-   **deps:** Allow protobuf 3.19.5 ([#&#8203;801](https://github.com/googleapis/python-pubsub/issues/801)) ([fa23503](https://github.com/googleapis/python-pubsub/commit/fa235033481783c2ec378b2a26b223bdff206461))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/python-asset).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMzAuMCIsInVwZGF0ZWRJblZlciI6IjMyLjIzMC4wIn0=-->
parthea pushed a commit that referenced this issue Oct 21, 2023
* docs: Add documentation for enums

fix: Add context manager return types

chore: Update gapic-generator-python to v1.8.1
PiperOrigin-RevId: 503210727

Source-Link: googleapis/googleapis@a391fd1

Source-Link: googleapis/googleapis-gen@0080f83
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDA4MGY4MzBkZWMzN2MzMzg0MTU3MDgyYmNlMjc5ZTM3MDc5ZWE1OCJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this issue Oct 21, 2023
* chore: Update gapic-generator-python to v1.11.7

PiperOrigin-RevId: 573230664

Source-Link: googleapis/googleapis@93beed3

Source-Link: googleapis/googleapis-gen@f4a4eda
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZjRhNGVkYWE4MDU3NjM5ZmNmNmFkZjkxNzk4NzIyODBkMWE4ZjY1MSJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea added a commit that referenced this issue Oct 22, 2023
* test: use mock from unittest

* Use `from unittest import mock`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants