-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
JavaDoc not clear as it could be, e.g. Datastore.add vs. Datastore.put #1339
Comments
|
Lol I'm not British but I would say you're being "dodgy". put is clear. Upsert is clear. What does "add" do? You didn't confirm or deny my assumption in the original question. "Add" isn't really documented. |
I have no idea what you mean with "clobber". I thought add behavior was straightforward, it adds an entity, in other words it performs a Datastore insert. More details on datastore operations can be found at https://cloud.google.com/datastore/docs/concepts/entities. |
A well "clobber" is an old school computer science term. Very technical. It means overwrite existing data. So... will "add" ever overwrite existing data? If not is there a way to know which ones were already present? (let's assume I'm adding 100 entities and half might already in the datastore). Will it throw an exception? Lots of potential questions. I'm just an API user trying to swim. I actually need this functionality of "add" that would add only those things not already present... leave existing datastore items alone. I'm testing. But I just wish I didn't have to. |
@unitydynamics, add() is equivalent to insert. If you try to insert an entity and the same key already exists, you will get an exception stating that fact. Your existing entity with the same key will be unaffected. |
I get that now... I just wish that the "add" documentation had at least a brief statement saying that existing entities were not overwritten and explained what happens if it does already exist. Moreover I wish the documentation defined the behavior for multiple entities being inserted at the same time, some of which are not in the data store yet and some of which already are. If you don't document the basic behaviors (preferably in JavaDoc) then you'll get clueless people like me asking questions like this. Let's close this issue. Thank you for your time and hard work on this API. |
@unitydynamics Here are some more details:
You might find strange that BTW, you are totally right when saying that this must be added to our javadoc. Please keep this issue open until I add more docs. |
Wow. Above and beyond! Good clarifications all around, updated Datastore interface, added some good tests. I like that you can get whatever behavior you want using transactions. Thanks Marco! |
🤖 I have created a release *beep* *boop* --- ### [1.2.2](googleapis/java-resourcemanager@v1.2.1...v1.2.2) (2022-02-03) ### Dependencies * **java:** update actions/github-script action to v5 ([googleapis#1339](https://github.com/googleapis/java-resourcemanager/issues/1339)) ([googleapis#705](googleapis/java-resourcemanager#705)) ([1be3785](googleapis/java-resourcemanager@1be3785)) * update dependency com.google.apis:google-api-services-cloudresourcemanager to v1-rev20220109-1.32.1 ([googleapis#702](googleapis/java-resourcemanager#702)) ([ef26145](googleapis/java-resourcemanager@ef26145)) * update dependency com.google.apis:google-api-services-cloudresourcemanager to v3 ([googleapis#692](googleapis/java-resourcemanager#692)) ([9428988](googleapis/java-resourcemanager@9428988)) * update dependency com.google.cloud:google-cloud-shared-dependencies to v2.7.0 ([googleapis#707](googleapis/java-resourcemanager#707)) ([1657de3](googleapis/java-resourcemanager@1657de3)) * update dependency com.google.errorprone:error_prone_annotations to v2.11.0 ([googleapis#704](googleapis/java-resourcemanager#704)) ([774890a](googleapis/java-resourcemanager@774890a)) * update dependency org.easymock:easymock to v4 ([googleapis#693](googleapis/java-resourcemanager#693)) ([a57f241](googleapis/java-resourcemanager@a57f241)) --- 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: googleapis/synthtool@466412a Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:7062473f423f339256346ddbee3d81fb1de6b784fabc2a4d959d7df2c720e375 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- ### [2.1.6](googleapis/java-workflows@v2.1.5...v2.1.6) (2022-02-03) ### Dependencies * **java:** update actions/github-script action to v5 ([#1339](https://github.com/googleapis/java-workflows/issues/1339)) ([#403](googleapis/java-workflows#403)) ([f2a7001](googleapis/java-workflows@f2a7001)) * update dependency com.google.cloud:google-cloud-shared-dependencies to v2.7.0 ([#406](googleapis/java-workflows#406)) ([75a6ecd](googleapis/java-workflows@75a6ecd)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
What's the difference between Datastore.add and Datastore.put?
Am I right in assuming that "add" will not clobber existing entities?
Maybe a quick update to the javadoc to clarify--would be much appreciated!!!
The text was updated successfully, but these errors were encountered: