-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Implements group_by, projection and offset on datastore Query. #282
Implements group_by, projection and offset on datastore Query. #282
Conversation
How is this PR different from #281? |
From #281:
This PR has only the new features and none of the regression tests. |
8dcf9f4
to
104345a
Compare
Rebased after the Travis fix. @tseaver PTAL |
104345a
to
8df6f41
Compare
Implementation LGTM, although I don't know these bits of the API at all. Does 'offset()' conflict with the cursor stuff? |
No, they are complimentary. We can get final sign-off from one of the datastore folks if you like? |
8df6f41
to
3d4ce5d
Compare
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. |
They would both be equal. See 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. |
I don't understand why it isn't just:
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. |
To give a simplified idea of what is happening in >>> 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'' |
b61ba2e
to
c27a8d5
Compare
c27a8d5
to
330ffc5
Compare
Rebased after #289. @tseaver does the explanation above make sense for allowing null values in
|
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. |
330ffc5
to
95528d2
Compare
This issue surfaced during review for googleapis#282.
@tseaver it turns out we weren't handling namespaces quite perfectly. See #292. As for dataset ID, the comment I added in To fully support this, we'd (at least) need to change 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
|
Source-Link: googleapis/synthtool@571ee2c Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:660abdf857d3ab9aabcd967c163c70e657fcc5653595c709263af5f3fa23ef67
fix(deps): require proto-plus >= 1.22.0
* fix(deps): allow protobuf 3.19.5 * explicitly exclude protobuf 4.21.0
Source-Link: googleapis/synthtool@c4dd595 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:ce3c1686bc81145c81dd269bd12c4025c6b275b22d14641358827334fddb1d72
…splay_name" (#282) - [ ] Regenerate this pull request now. docs: Update documentation for the Mute fields on Findings PiperOrigin-RevId: 429148908 Source-Link: googleapis/googleapis@c93764c Source-Link: googleapis/googleapis-gen@8810468 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODgxMDQ2ODhmZmYzN2M2N2ZmNzJhZGRiNzNmM2ZlNjFkMTlkYzg1YSJ9
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
) Source-Link: googleapis/synthtool@c1dd87e Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:2d13c2172a5d6129c861edaa48b60ead15aeaf58aa75e02d870c4cbdfa63aaba Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Source-Link: googleapis/synthtool@6fab84a Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe
Source-Link: https://github.com/googleapis/synthtool/commit/909573ce9da2819eeb835909c795d29aea5c724e Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:ddf4551385d566771dc713090feb7b4c1164fb8a698fe52bbe7670b24236565b
…p/templates/python_library/.kokoro (#282) Source-Link: https://github.com/googleapis/synthtool/commit/bb171351c3946d3c3c32e60f5f18cee8c464ec51 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:f62c53736eccb0c4934a3ea9316e0d57696bb49c1a7c86c726e9bb8a2f87dadf
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 459095142 Source-Link: googleapis/googleapis@4f1be99 Source-Link: googleapis/googleapis-gen@ae686d9 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWU2ODZkOWNkZTRmYzNlMzZkMGFjMDJlZmI4NjQzYjE1ODkwYzFlZCJ9 feat: add audience parameter PiperOrigin-RevId: 456827138 Source-Link: googleapis/googleapis@23f1a15 Source-Link: googleapis/googleapis-gen@4075a85 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDA3NWE4NTE0ZjY3NjY5MWVjMTU2Njg4YTViYmYxODNhYTk4OTNjZSJ9
Source-Link: googleapis/synthtool@69fabae Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:562802bfac02e012a6ac34eda282f81d06e77326b82a32d7bbb1369ff552b387
🤖 I have created a release \*beep\* \*boop\* --- ### [3.3.1](https://www.github.com/googleapis/python-dlp/compare/v3.3.0...v3.3.1) (2021-11-05) ### Bug Fixes * **deps:** drop packaging dependency ([84181e9](https://www.github.com/googleapis/python-dlp/commit/84181e971ee04b46a603119d44410816fd7f04be)) * **deps:** require google-api-core >= 1.28.0 ([84181e9](https://www.github.com/googleapis/python-dlp/commit/84181e971ee04b46a603119d44410816fd7f04be)) * fix extras_require typo in setup.py ([84181e9](https://www.github.com/googleapis/python-dlp/commit/84181e971ee04b46a603119d44410816fd7f04be)) ### Documentation * list oneofs in docstring ([84181e9](https://www.github.com/googleapis/python-dlp/commit/84181e971ee04b46a603119d44410816fd7f04be)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
* 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>
Source-Link: googleapis/synthtool@56da63e Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:993a058718e84a82fda04c3177e58f0a43281a996c7c395e0a56ccc4d6d210d7
fix(deps): require proto-plus>=1.15.0
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
This adds region tags in order to support the Cloud Code API Explorer pilot
🤖 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).
Source-Link: https://github.com/googleapis/synthtool/commit/352b9d4c068ce7c05908172af128b294073bf53c Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:3e3800bb100af5d7f9e810d48212b37812c1856d20ffeafb99ebe66461b61fc7
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
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.