10000 Fix: Datastore samples: `exclude_from_indexes` expects a tuple, not a… · sreza/python-docs-samples@1cd2422 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1cd2422

Browse files
authored
Fix: Datastore samples: exclude_from_indexes expects a tuple, not a… (GoogleCloudPlatform#8233)
… list Updated the sample to pass in a tuple instead of a list. Also ensure that we call client.put() so the changes persist. Fix internal issue 233485333 ## Description Fixes #<ISSUE-NUMBER> Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google. ## Checklist - [x] I have followed [Sample Guidelines from AUTHORING_GUIDE.MD](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md) - [ ] README is updated to include [all relevant information](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md#readme-file) - [x] **Tests** pass: `nox -s py-3.9` (see [Test Environment Setup](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md#test-environment-setup)) - [x] **Lint** pass: `nox -s lint` (see [Test Environment Setup](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md#test-environment-setup)) - [ ] These samples need a new **API enabled** in testing projects to pass (let us know which ones) - [ ] These samples need a new/updated **env vars** in testing projects set to pass (let us know which ones) - [x] Please **merge** this PR for me once it is approved. - [ ] This sample adds a new sample directory, and I updated the [CODEOWNERS file](https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/.github/CODEOWNERS) with the codeowners for this sample
1 parent f5fed5f commit 1cd2422

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

datastore/cloud-client/snippets.py

Lines changed: 2 additions & 1 deletion
8000
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def entity_with_parent(client):
213213
def properties(client):
214214
# [START datastore_properties]
215215
key = client.key("Task")
216-
task = datastore.Entity(key, exclude_from_indexes=["description"])
216+
task = datastore.Entity(key, exclude_from_indexes=("description",))
217217
task.update(
218218
{
219219
"category": "Personal",
@@ -224,6 +224,7 @@ def properties(client):
224224
"percent_complete": 10.5,
225225
}
226226
)
227+
client.put(task)
227228
# [END datastore_properties]
228229

229230
return task

datastore/cloud-client/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def add_task(client: datastore.Client, description: str):
4545

4646
# Create an unsaved Entity object, and tell Datastore not to index the
4747
# `description` field
48-
task = datastore.Entity(key, exclude_from_indexes=["description"])
48+
task = datastore.Entity(key, exclude_from_indexes=("description",))
4949

5050
# Apply new field values and save the Task entity to Datastore
5151
task.update(

0 commit comments

Comments
 (0)
0