Skip to content

Conversation

@dhermes
Copy link
Contributor

@dhermes dhermes commented Oct 22, 2014

In addition, __eq__ was implemented on datastore.key.Key to allow for easy comparison.

See #281 for some context. As mentioned there, I looked and didn't see any equivalent bugs for these features.

@tseaver
Copy link
Contributor

tseaver commented Oct 22, 2014

How is this PR different from #281?

@tseaver tseaver added the api: datastore Issues related to the Datastore API. label Oct 22, 2014
@dhermes
Copy link
Contributor Author

dhermes commented Oct 22, 2014

From #281:

As new Query features are outside the scope of functional / regression testing, I am going
to peel them off into a separate PR and then rebase this one onto it after that is reviewed.
However, please feel free to dig into this review.

This PR has only the new features and none of the regression tests.

@dhermes dhermes force-pushed the implement-groupby-projection-offset branch 2 times, most recently from 8dcf9f4 to 104345a Compare October 22, 2014 21:33
@dhermes
Copy link
Contributor Author

dhermes commented Oct 22, 2014

Rebased after the Travis fix.

@tseaver PTAL

@dhermes dhermes force-pushed the implement-groupby-projection-offset branch from 104345a to 8df6f41 Compare October 22, 2014 21:53
@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 8df6f41 on dhermes:implement-groupby-projection-offset into 9884f77 on GoogleCloudPlatform:master.

@tseaver
Copy link
Contributor

tseaver commented Oct 22, 2014

Implementation LGTM, although I don't know these bits of the API at all. Does 'offset()' conflict with the cursor stuff?

@dhermes
Copy link
Contributor Author

dhermes commented Oct 23, 2014

No, they are complimentary. We can get final sign-off from one of the datastore folks if you like?

@dhermes dhermes force-pushed the implement-groupby-projection-offset branch from 8df6f41 to 3d4ce5d Compare October 23, 2014 00:50
@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 3d4ce5d on dhermes:implement-groupby-projection-offset into 2da8654 on GoogleCloudPlatform:master.

@dhermes
Copy link
Contributor Author

dhermes commented Oct 23, 2014

@tseaver while fixing some failures in #281 I realized #274 made key equality a bit of a different animal.

I added b61ba2e to address some corner cases.

You'll notice that this is a bit unpleasant. ISTM we should work harder to make the underlying representation of a Key simpler. /cc @pcostell

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling b61ba2e on dhermes:implement-groupby-projection-offset into 2da8654 on GoogleCloudPlatform:master.

@tseaver
Copy link
Contributor

tseaver commented Oct 23, 2014

I still don't see why two keys, each with 'dataset_id == None' but having the same path, should be unequal (they are both in the "default" dataset for the application's connection).

Likewise for when both keys have 'namespace == None' but the same path.

@dhermes
Copy link
Contributor Author

dhermes commented Oct 23, 2014

They would both be equal. See test_key___eq__.

The failures happen if (dataset as an example)

        if not (self._dataset_id == other._dataset_id or
                self._dataset_id is None or other._dataset_id is None):

which is equivalent to

        if (self._dataset_id != other._dataset_id and
            self._dataset_id is not None and other._dataset_id is not None):

In other words, failure only occurs if the values don't match AND both values are non-null.

@tseaver
Copy link
Contributor

tseaver commented Oct 23, 2014

I don't understand why it isn't just:

if self._dataset_id != other._dataset_id:

If they are both None, they will be equal; if either is not None but the other is, they won't be equal. None compares for equality fine with arbitrary objects.

@dhermes
Copy link
Contributor Author

dhermes commented Oct 23, 2014

To give a simplified idea of what is happening in test_post_with_generated_id, test_post_with_id and test_post_with_name:

>>> import regression.regression_utils
>>> dataset = regression.regression_utils.get_dataset()
>>> entity = dataset.entity(kind='SomeKind')
>>> entity['key'] = 'value'
>>> key = entity.key().name('some_name')  # Same for partial key or key id.
>>> entity = entity.key(key)
>>> entity.save()
<Entity[{'kind': 'SomeKind', 'name': 'some_name'}] {'key': 'value'}>
>>> retrieved_entity = dataset.get_entity(entity.key())

then we'll have

>>> entity.key().path()
[{'kind': 'SomeKind', 'name': 'some_name'}]
>>> retrieved_entity.key().path()
[{'kind': u'SomeKind', 'name': u'some_name'}]
>>> 
>>> print entity.key()._dataset_id
None
>>> retrieved_entity.key()._dataset_id
u's~redacted-dataset-id'
>>>
>>> print entity.key()._namespace
None
>>> retrieved_entity.key()._namespace
u''

@dhermes dhermes force-pushed the implement-groupby-projection-offset branch from b61ba2e to c27a8d5 Compare October 23, 2014 18:38
@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling c27a8d5 on dhermes:implement-groupby-projection-offset into 09859db on GoogleCloudPlatform:master.

@dhermes dhermes force-pushed the implement-groupby-projection-offset branch from c27a8d5 to 330ffc5 Compare October 23, 2014 20:40
@dhermes
Copy link
Contributor Author

dhermes commented Oct 23, 2014

Rebased after #289.

@tseaver does the explanation above make sense for allowing null values in __eq__? Do you think we should do some more work to make these values actually agree?

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 330ffc5 on dhermes:implement-groupby-projection-offset into 8a21978 on GoogleCloudPlatform:master.

@tseaver
Copy link
Contributor

tseaver commented Oct 23, 2014

Yes, I see what you are trying to accomplish now. WRT the key's _datset_id, I'm not positive we want None to compare equal to one with an ID set by the back-end: it is sort of like comparing a naive datetime to a zoned one: they will be the same now, but later (if multi-dataset access comes into play) they might not be.

WRT namespace: we could switch the default value from None to '', and then just compare them naturally.

@dhermes dhermes force-pushed the implement-groupby-projection-offset branch from 330ffc5 to 95528d2 Compare October 23, 2014 23:01
@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 95528d2 on dhermes:implement-groupby-projection-offset into b6d3e74 on GoogleCloudPlatform:master.

dhermes added a commit to dhermes/google-cloud-python that referenced this pull request Oct 23, 2014
@dhermes
Copy link
Contributor Author

dhermes commented Oct 24, 2014

@tseaver it turns out we weren't handling namespaces quite perfectly. See #292.

As for dataset ID, the comment I added in Entity.save() to #292 may be the best strategy (i.e. if the key starts implicit, it should stay implicit).

To fully support this, we'd (at least) need to change Dataset.get_entities since it just creates each entity via helpers.entity_from_protobuf without any regard to the original values in keys().

A simple solution to this could be changing

        for entity_pb in entity_pbs:
            entities.append(helpers.entity_from_protobuf(
                entity_pb, dataset=self))

to

        for entity_pb, curr_key in zip(entity_pbs, keys):
            curr_entity = helpers.entity_from_protobuf(
                entity_pb, dataset=self)
            # If original key was implicit, maintain this on the
            # returned entity.
            if curr_key._dataset_id is None:
                curr_entity.key()._dataset_id = None
            else:
                if curr_entity.key() != curr_key:
                    raise ValueError('Key returned disagrees with key used '
                                     'in query.')
            entities.append(curr_entity)

parthea pushed a commit that referenced this pull request Sep 22, 2023
* chore: Update gapic-generator-python to v1.11.2

PiperOrigin-RevId: 546510849

Source-Link: googleapis/googleapis@736073a

Source-Link: googleapis/googleapis-gen@deb64e8
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZGViNjRlOGVjMTlkMTQxZTMxMDg5ZmU5MzJiM2E5OTdhZDU0MWM0ZCJ9

* 🦉 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 pull request Sep 22, 2023
Source-Link: googleapis/synthtool@56da63e
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:993a058718e84a82fda04c3177e58f0a43281a996c7c395e0a56ccc4d6d210d7
parthea added a commit that referenced this pull request Sep 22, 2023
fix(deps): require proto-plus>=1.15.0
parthea pushed a commit that referenced this pull request Oct 21, 2023
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Oct 21, 2023
This adds region tags in order to support the Cloud Code API Explorer pilot
parthea pushed a commit that referenced this pull request Oct 21, 2023
🤖 I have created a release \*beep\* \*boop\*
---
### [3.6.1](https://www.github.com/googleapis/python-translate/compare/v3.6.0...v3.6.1) (2021-11-04)


### Bug Fixes

* **deps:** drop packaging dependency ([7924322](https://www.github.com/googleapis/python-translate/commit/79243222e5e16e1b7cb50b9d69862ddf6023ad4f))
* **deps:** require google-api-core >= 1.28.0 ([7924322](https://www.github.com/googleapis/python-translate/commit/79243222e5e16e1b7cb50b9d69862ddf6023ad4f))


### Documentation

* list oneofs in docstring ([7924322](https://www.github.com/googleapis/python-translate/commit/79243222e5e16e1b7cb50b9d69862ddf6023ad4f))
* **samples:** Add Cloud Code tags for API Explorer pilot ([#282](https://www.github.com/googleapis/python-translate/issues/282)) ([3e8df68](https://www.github.com/googleapis/python-translate/commit/3e8df6836f0508fb4c6cd1c4a9f2f39192a01cea))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
parthea added a commit that referenced this pull request Oct 21, 2023
parthea pushed a commit that referenced this pull request Oct 22, 2023
Source-Link: https://togithub.com/googleapis/synthtool/commit/352b9d4c068ce7c05908172af128b294073bf53c
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:3e3800bb100af5d7f9e810d48212b37812c1856d20ffeafb99ebe66461b61fc7
parthea pushed a commit that referenced this pull request Oct 22, 2023
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Sep 18, 2025
#282)

Tests were failing because the `str` method for the context returned by
`pytest.raises` no longer prints the contained exception. Instead, use
`match=regex_value` to check for the desired error message.
parthea pushed a commit that referenced this pull request Nov 22, 2025
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Nov 24, 2025
parthea pushed a commit that referenced this pull request Nov 24, 2025
add test cases for interceptor
parthea pushed a commit that referenced this pull request Nov 24, 2025
…p/templates/python_library/.kokoro (#282)

Source-Link: googleapis/synthtool@d0f51a0
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:240b5bcc2bafd450912d2da2be15e62bc6de2cf839823ae4bf94d4f392b451dc

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea added a commit that referenced this pull request Nov 24, 2025
…282)

* chore: add default_version and codeowner_team to .repo-metadata.json

* Assign @googleapis/actools-python as codeowner
parthea pushed a commit that referenced this pull request Nov 24, 2025
… and bigquery (#282)

* chore(deps): update dependency charset-normalizer to v2.0.4

* 🦉 Updates from OwlBot

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

* chore(deps): update dependency google-cloud-bigquery-storage to v2.6.3

* chore(deps): update dependency google-resumable-media to v1.3.3

* 🦉 Updates from OwlBot

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

* 🦉 Updates from OwlBot

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

* chore(deps): update dependency greenlet to v1.1.1

* chore(deps): update dependency importlib-metadata to v4.6.4

* 🦉 Updates from OwlBot

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

* 🦉 Updates from OwlBot

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

* chore(deps): update dependency libcst to v0.3.20

* chore(deps): update dependency pybigquery to v0.10.1

* 🦉 Updates from OwlBot

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

* 🦉 Updates from OwlBot

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

* chore(deps): update dependency dataclasses to v0.8

* chore(deps): update dependency google-auth to v1.35.0

* 🦉 Updates from OwlBot

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

* 🦉 Updates from OwlBot

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

* chore(deps): update dependency google-cloud-bigquery to v2.24.0

* 🦉 Updates from OwlBot

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

* chore(deps): update dependency numpy to v1.21.2

* chore(deps): update dependency pandas to v1.3.2

* 🦉 Updates from OwlBot

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

* 🦉 Updates from OwlBot

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

* chore(deps): update dependency pyproj to v3.1.0

* 🦉 Updates from OwlBot

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

* chore(deps): update dependency google-auth to v2

* 🦉 Updates from OwlBot

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

* Update requirements.txt

* minor sorting

* chore(deps): update dependency sqlalchemy to v1.4.23

* Use older pyproj for Python 3.6

* Use older version of pandas for Python 3.6

* Use older numpy for Python 3.6

* Use older dataclasses for Python 3.8 and earlier

* Don't need dataclasses for 3.7 and later, as they're in the standard library

* chore(deps): update dependency google-api-core to v2

* chore(deps): update dependency google-cloud-core to v2

* require google-cloud-bigquery 2.24.1 (or greater)

* Include tests dependencies in noxfile

* Include tests dependencies in noxfile for compliance tests

Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea added a commit that referenced this pull request Nov 24, 2025
* feat: add support for IN/NOT_IN/!= operator

* 🦉 Updates from OwlBot post-processor

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

* chore: fix tests

* chore: fix tests

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <[email protected]>
parthea pushed a commit that referenced this pull request Nov 24, 2025
Source-Link: googleapis/synthtool@9ae0785
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:52210e0e0559f5ea8c52be148b33504022e1faef4e95fbe4b32d68022af2fa7e

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Lingqing Gan <[email protected]>
parthea pushed a commit that referenced this pull request Nov 24, 2025
Source-Link: googleapis/synthtool@9ae0785
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:52210e0e0559f5ea8c52be148b33504022e1faef4e95fbe4b32d68022af2fa7e

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Nov 26, 2025
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants