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

DISCUSSION: Implement Key.__eq__ and Entity.__eq__ #533

Closed
dhermes opened this issue Jan 12, 2015 · 3 comments · Fixed by #615
Closed

DISCUSSION: Implement Key.__eq__ and Entity.__eq__ #533

dhermes opened this issue Jan 12, 2015 · 3 comments · Fixed by #615
Assignees
Labels
api: datastore Issues related to the Datastore API. type: question Request for information or clarification. Not an issue.

Comments

@dhermes
Copy link
Contributor

dhermes commented Jan 12, 2015

Currently comparison must be done in an ad-hoc way:

assert dict(arya_entity.items()) == {'name': 'Arya', 'family': 'Stark'})

FWIW __eq__ is not something that should really be needed outside of the Key, and even then not so much.

NOTE: This was a small part of #336

@dhermes dhermes added the api: datastore Issues related to the Datastore API. label Jan 12, 2015
@dhermes
Copy link
Contributor Author

dhermes commented Jan 12, 2015

FWIW I have implemented Key.__eq__ in https://github.com/dhermes/gcloud-python/tree/key-comparison but it greatly depends on the conversation in #528

@tseaver
Copy link
Contributor

tseaver commented Jan 12, 2015

Can we simplify by saying that incomplete keys never compare equal to anything? We shoudn't expect them to be super long-lived anyway, and the use-cases seem strongly biased toward "real" equivalence.

Note that we need to implement __hash__ as well for many sensible uses of __eq__.

@jgeewax jgeewax added this to the Datastore Stable milestone Jan 30, 2015
@jgeewax jgeewax added the type: question Request for information or clarification. Not an issue. label Feb 3, 2015
@jgeewax
Copy link
Contributor

jgeewax commented Feb 3, 2015

Just had a chat with @dhermes about "what does equality mean?". The current thinking is:

  • Equal key path
  • Equal entity data (dictionary equivalence)
  • Equal dataset_id (if dataset_id.startswith(s~ or e~): dataset_id = dataset_id[2:])

If people just want to compare the entity data, they can do a dict(entity) ==
If people just want to compare the key path, they can do a key.path ==

tseaver added a commit that referenced this issue Feb 12, 2015
Fix #533:  add key and entity equality methods
parthea pushed a commit that referenced this issue Jul 6, 2023
…s-samples#533)

* Add sentiment analysis sample
* Move sample review files into resources directory
* Remove blank line from end of file
* Update set up instructions to point to getting started guide
* Update README to remove need to set up gcloud. Itemize what setting
up a project entails.
* Update NL README to link to Sentiment tutorial code
* Coerce number types before comparison
parthea pushed a commit that referenced this issue Aug 15, 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>
vchudnov-g pushed a commit that referenced this issue Sep 20, 2023
… the CX page to override the `current_page` in the session (#533)

- [ ] Regenerate this pull request now.

docs: add more meaningful comments

PiperOrigin-RevId: 459325028

Source-Link: googleapis/googleapis@a076084

Source-Link: googleapis/googleapis-gen@278f4fd
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjc4ZjRmZGI0YTRlZjVmZjY4ZGEzZjQwZjMwMzY3Y2EzZTE3MTdiZiJ9

chore: use gapic-generator-python 1.1.1
PiperOrigin-RevId: 459095142

Source-Link: googleapis/googleapis@4f1be99

Source-Link: googleapis/googleapis-gen@ae686d9
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWU2ODZkOWNkZTRmYzNlMzZkMGFjMDJlZmI4NjQzYjE1ODkwYzFlZCJ9



PiperOrigin-RevId: 458520697

Source-Link: googleapis/googleapis@2bf9d8d

Source-Link: googleapis/googleapis-gen@ce2a70a
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiY2UyYTcwYWFkYWIxNTkzZDZkYWY4NjA5ZTVmZGQwY2YwYzY0NGJiYyJ9


PiperOrigin-RevId: 456827138

Source-Link: googleapis/googleapis@23f1a15

Source-Link: googleapis/googleapis-gen@4075a85
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDA3NWE4NTE0ZjY3NjY5MWVjMTU2Njg4YTViYmYxODNhYTk4OTNjZSJ9

feat: deprecated the filter field and add resource_definition
docs: add more meaningful comments
feat: add audience parameter
fix(deps): require google-api-core>=1.32.0,>=2.8.0
feat: Add filter field to ListAnswerRecordsRequest
feat: Add AudioInput to analysis requests
parthea pushed a commit that referenced this issue Oct 21, 2023
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this issue Oct 21, 2023
Source-Link: googleapis/synthtool@5f2a608
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:8555f0e37e6261408f792bfd6635102d2da5ad73f8f09bcb24f25e6afb5fac97

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this issue Oct 22, 2023
…533)

Source-Link: googleapis/synthtool@395d53a
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:6c1cbc75c74b8bdd71dada2fa1677e9d6d78a889e9a70ee75b93d1d0543f96e1

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
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: question Request for information or clarification. Not an issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants