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 — Require that keys for 'put' / 'delete' match the 'dataset_id' of the batch by tseaver · Pull Request #552 · googleapis/google-cloud-python

Conversation

@tseaver

@tseaver tseaver commented Jan 15, 2015

Copy link
Copy Markdown
Contributor

Fixes #447.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jan 15, 2015
@tseaver tseaver added the api: datastore Issues related to the Datastore API. label Jan 15, 2015
@coveralls

coveralls commented Jan 15, 2015

Copy link
Copy Markdown

Coverage Status

Coverage remained the same when pulling b6ccf75 on tseaver:447-require_key_dataset_ids_match_branch into 12ac983 on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Jan 15, 2015

Copy link
Copy Markdown
Contributor

Shall we also ditch _get_dataset_id_from_keys and just rely on this behavior?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Jan 15, 2015

Copy link
Copy Markdown
Contributor Author

_get_dataset_id_from_keys is used by datastore.get, too, and is used to figure out which dataset_id to use in datastore.put and datastore.delete when no batch / transaction is already in play.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Jan 15, 2015

Copy link
Copy Markdown
Contributor

OK so let's not remove, but it doesn't make sense to check them at the beginning and then again when each Key / Entity is passed to Batch.put() / Batch.delete().

Proposal:

  • Stop using _get_dataset_id_from_keys in put() and delete().
  • Introduce optional dataset_id=None parameter to put() and delete()
  • Fall back to implicit if no dataset ID is passed
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Jan 15, 2015

Copy link
Copy Markdown
Contributor Author

SGTM: For consistency, get() should work the same way.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Jan 15, 2015

Copy link
Copy Markdown
Contributor

But get() is not tied to a batch. How do you mean the same way?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Jan 15, 2015

Copy link
Copy Markdown
Contributor Author

I just mean that the API should be consistent: get() should take an optional dataset_id, and fall back to the implicit one, rather than deriving it from the keys (it should still check the keys to ensure that they all match).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Jan 15, 2015

Copy link
Copy Markdown
Contributor

SGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver tseaver mentioned this pull request Jan 15, 2015
Adding one-time RPC to find unaliased / true dataset ID. #528
Closed
@tseaver

tseaver commented Jan 15, 2015

Copy link
Copy Markdown
Contributor Author

I'm adding a variant on the "inferred connection / dataset ID" bit: if there is an active batch or transaction, and you don't pass them to datastore.get() / datastore.put() / datastore.delete(), then we use the value set on the batch or transaction.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coveralls

coveralls commented Jan 15, 2015

Copy link
Copy Markdown

Coverage Status

Coverage remained the same when pulling 9006e61 on tseaver:447-require_key_dataset_ids_match_branch into be8f5fb on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Jan 15, 2015

Copy link
Copy Markdown
Contributor

RE: Doing the right thing comparing dataset_ids, instead of waiting on #528, how do you feel about just moving regression.datastore._compare_dataset_ids into gcloud.datastore.api?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Jan 15, 2015

Copy link
Copy Markdown
Contributor

RE: variant of implicit, that seems to be the right move. Reviewing now.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dhermes
dhermes reviewed Jan 15, 2015
View reviewed changes
Comment thread gcloud/datastore/api.py Outdated

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Jan 15, 2015

Copy link
Copy Markdown
Contributor Author

I forgot regression.datastore._compare_dataset_ids was there, and implemented a stripped-down variant in Batch._match_dataset_id (1b87a7e)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Jan 15, 2015

Copy link
Copy Markdown
Contributor

Yes I just saw it in the review. Unfortunately it would gave false positives like e~foo == s~foo and s~foo == s~notfoo~foo. (These are not likely to be possible values in the wild, but better safe than sorry.)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Jan 15, 2015

Copy link
Copy Markdown
Contributor Author

For a given "project ID" (the un-prefixed dataset ID), is it possible to have more than one prefix? I'm pretty sure that the project IDs themselves will never have an embedded ~: why else would they have picked it to delimit the "location"-based IDs?

At any rate, we could move the regression.datastore_compare_dataset_ids code into helpers, and call it from within _match_dataset_id (which wants to raise an error).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Jan 15, 2015

Copy link
Copy Markdown
Contributor

I'm fairly certain the two cases I described are impossible, but the extra effort required is minimal since I've already written the code and the tests.

Moving to helpers SGTM, take a peek at
dhermes@90d5063
for _dataset_ids_equal and Test__dataset_ids_equal.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coveralls

coveralls commented Jan 15, 2015

Copy link
Copy Markdown

Coverage Status

Coverage remained the same when pulling ae880b4 on tseaver:447-require_key_dataset_ids_match_branch into be8f5fb on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Jan 15, 2015

Copy link
Copy Markdown
Contributor Author

Are you working to merge dhermes/google-cloud-python@90d5063? If so, we should update _match_dataset_id to use your helper function afterwards.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Jan 15, 2015

Copy link
Copy Markdown
Contributor

I am holding off on it until #528 has some sort of resolution, since it doesn't solve an actual problem, just gives "nice" behavior.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Jan 15, 2015

Copy link
Copy Markdown
Contributor

RE: Impossibility of ordering

I think you're correct that without pathological things like

key = Key('Foo')
key._dataset_id = None

the last one can't occur.


I spoke too soon in my recommendation. As implemented, the following will fail but should not:

from gcloud import datastore
datastore.set_defaults(dataset_id='foo')

k = Key('Kind', 10, dataset_id='bar')
datastore.delete([k])

With this, api.delete() will create a new Batch with dataset_id = 'foo' and then will result in an error when Batch.delete() is called on this new batch.

This is why the ordering

  • dataset_id if passed explicitly
  • Batch.current().dataset_id
  • entities[0].key.dataset_id
  • _implicit_environ.DATASET_ID

is necessary.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tseaver

tseaver commented Jan 22, 2015

Copy link
Copy Markdown
Contributor Author

This is why the ordering

  • dataset_id if passed explicitly
  • Batch.current().dataset_id
  • entities[0].key.dataset_id
  • _implicit_environ.DATASET_ID

I think the last is a "can't get there" case, because keys will always have a dataset_id. If that is so, I can update the PR to match.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Jan 22, 2015

Copy link
Copy Markdown
Contributor

It's not the Keys we're worried about, it's the Batch (more than just Key uses the default). See the scenario I mentioned below the 1st line above.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tseaver added 3 commits January 27, 2015 13:02
@tseaver
Require that keys for 'put' / 'delete' match the 'dataset_id' of the …
5aa16a5
…batch.

Fixes #447.
@tseaver
Remove '_get_dataset_id_from_keys'.
24b9b8e
@tseaver
Work around the fact that keys updated from the server have prefixes.
9bb4a3f
See #528.
tseaver added 2 commits January 27, 2015 18:30
@tseaver
Fix typos.
d198d69
Incorporates feedback from @dhermes:

- #552 (comment)

- #552 (comment)
@tseaver
Rework '_require_dataset_id' to avoid making caller pass all keys.
db4c728
Instead, caller passes only the first key.

Incorporates feedback from @dhermes:

- #552 (comment)
@tseaver

tseaver commented Jan 27, 2015

Copy link
Copy Markdown
Contributor Author

@dhermes no worries.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coveralls

coveralls commented Jan 27, 2015

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling db4c728 on tseaver:447-require_key_dataset_ids_match_branch into 6bbb144 on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Jan 27, 2015

Copy link
Copy Markdown
Contributor

@tseaver Everything looks good except moving _match_dataset_id to helpers and using the implementation / tests from dhermes@90d5063

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tseaver added 2 commits January 28, 2015 12:02
@tseaver
Land '_dataset_ids_equal' in helpers.
a6cea31
From dhermes@90d5063.
@tseaver
Use 'helpers._dataset_ids_equal'.
49977da
@tseaver

tseaver commented Jan 28, 2015

Copy link
Copy Markdown
Contributor Author

@dhermes PTAL

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coveralls

coveralls commented Jan 28, 2015

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 100.0% when pulling 49977da on tseaver:447-require_key_dataset_ids_match_branch into 6bbb144 on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dhermes

dhermes commented Jan 28, 2015

Copy link
Copy Markdown
Contributor

LGTM

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tseaver added a commit that referenced this pull request Jan 28, 2015
@tseaver
Merge pull request #552 from tseaver/447-require_key_dataset_ids_matc…
2c75763
…h_branch

Require that keys for 'put' / 'delete' match the 'dataset_id' of the batch
@tseaver
tseaver merged commit 2c75763 into googleapis:master Jan 28, 2015
@tseaver
tseaver deleted the 447-require_key_dataset_ids_match_branch branch January 28, 2015 17:26
vchudnov-g pushed a commit that referenced this pull request Sep 20, 2023
@gcf-owl-bot
chore(deps): update actions/setup-python action to v4 [autoapprove] (#…
bd6f31b
…552)

Source-Link: googleapis/synthtool@8e55b32
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:c6c965a4bf40c19011b11f87dbc801a66d3a23fbc6704102be064ef31c51f1c3
parthea added a commit that referenced this pull request Oct 21, 2023
@gcf-owl-bot @parthea
chore: Update gapic-generator-python to v1.8.5 (#552)
7f49d43
* chore: Update gapic-generator-python to v1.8.5

PiperOrigin-RevId: 511892190

Source-Link: googleapis/googleapis@a45d9c0

Source-Link: googleapis/googleapis-gen@1907294
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTkwNzI5NGIxZDgzNjVlYTI0ZjhjNWYyZTA1OWE2NDEyNGM0ZWQzYiJ9

* 🦉 Updates from OwlBot post-processor

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

* revert

---------

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 Oct 21, 2023
@gcf-owl-bot
docs: Minor formatting (#552)
7344559
* docs: Minor formatting
chore: Update gapic-generator-python to v1.11.5
build: Update rules_python to 0.24.0

PiperOrigin-RevId: 563436317

Source-Link: googleapis/googleapis@42fd37b

Source-Link: googleapis/googleapis-gen@280264c
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjgwMjY0Y2EwMmZiOTMxNmI0MjM3YTk2ZDBhZjFhMjM0M2E4MWE1NiJ9

* 🦉 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>
@release-please release-please Bot mentioned this pull request Oct 27, 2023
chore: release main #11913
Merged
parthea added a commit that referenced this pull request Aug 21, 2025
@renovate-bot @parthea
chore(deps): update dependency pandas to v1.5.3 (#552)
1a5aa4e
Co-authored-by: Anthonios Partheniou <[email protected]>
parthea added a commit that referenced this pull request Sep 16, 2025
@renovate-bot @parthea
chore(deps): update dependency pandas to v1.5.3 (#552)
ec105fe
Co-authored-by: Anthonios Partheniou <[email protected]>
parthea added a commit that referenced this pull request Nov 22, 2025
@parthea @gcf-owl-bot
chore: allow releases on previous major versions (#552)
2269c6b
* chore: allow releases on previous major versions

* 🦉 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 Nov 24, 2025
@release-please @software-dov
chore: release 0.29.2 (#552)
835d82e
* updated CHANGELOG.md [ci skip]

* updated setup.py

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Dov Shlachter <[email protected]>
parthea added a commit that referenced this pull request Nov 24, 2025
@DouglasBlackwood @parthea
fix: replace deprecated datetime.datetime.utcnow() (#552)
552d52b
Fixes #540

Co-authored-by: Anthonios Partheniou <[email protected]>
parthea pushed a commit that referenced this pull request Nov 24, 2025
@gkevinzheng @gcf-owl-bot @daniel-sanche
fix: Using end_cursor instead of skipped_cursor in Iterator to fix ra…
39a6f89
…re bug. (#552)

* fix: Using end_cursor instead of skipped_cursor in Iterator to fix rare
bug.

* 🦉 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>
Co-authored-by: Daniel Sanche <[email protected]>
parthea added a commit that referenced this pull request Nov 24, 2025
@parthea @gcf-owl-bot
chore: allow releases on previous majors (#552)
f724ba7
* chore: allow releases on previous majors

* 🦉 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 Nov 24, 2025
Chris Rossi
fix: @non_transactional decorator was not working correctly with as…
eba1f19
…ync (#554)

* fix: `@non_transactional` decorator was not working correctly with async

Fixes #552

* We don't really need `_get_transaction` at all.

In all cases, we know where to get the transaction from.
parthea pushed a commit that referenced this pull request Nov 26, 2025
@release-please
chore: release 1.19.0 (#552)
eae26de
* updated CHANGELOG.md [ci skip]

* updated setup.cfg [ci skip]

* updated setup.py

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Mar 2, 2026
@plamut
fix: refactor client classes for safer type checking (#552)
bc600bb
* Directly subclass generated PublisherClient

* Directly subclass generated SubscriberClient

* Remove unneded GAPIC helper

* Remove pytype

There are no real advantages over mypy, but at the same time several
downsides such as being slow, producing more false positives, etc.

* Re-enable mypy_samples nox session

* Convert a comment to docstring in publisher client

* Add api property back, but deprecated

* Assure that mypy_samples is not commented out

* Remove redundant type hint casts

* Disable mypy_samples session until blockers resolved
parthea pushed a commit that referenced this pull request Mar 6, 2026
@yoshi-automation
chore: add pre-commit-config to renovate ignore paths (#552)
6a908a1
Disable renovate PRs on the .pre-commit-config.yaml which is templated from synthtool. https://docs.renovatebot.com/configuration-options/#ignorepaths

Source-Author: Bu Sun Kim <[email protected]>
Source-Date: Mon Mar 15 09:05:39 2021 -0600
Source-Repo: googleapis/synthtool
Source-Sha: 2c54c473779ea731128cea61a3a6c975a08a5378
Source-Link: googleapis/synthtool@2c54c47
parthea pushed a commit that referenced this pull request Mar 9, 2026
@renovate-bot
chore(deps): update dependency opentelemetry-sdk to v1.29.0 (#552)
10048be
parthea pushed a commit that referenced this pull request Mar 9, 2026
@tseaver
tests: harden 'test_bucket_w_retention_period' vs EC (#552)
5015c49
Closes #551.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

api: datastore Issues related to the Datastore API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Batch (and Transaction) dataset_id should match that of Key / Query objects when added

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@tseaver @coveralls @dhermes @googlebot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.