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

feat: [Datastore] New PropertyMask field which allows partial commits, lookups, and query results #7321

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Datastore/metadata/V1/Datastore.php
Binary file not shown.
22 changes: 22 additions & 0 deletions Datastore/src/V1/Gapic/DatastoreGapicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
use Google\Cloud\Datastore\V1\LookupResponse;
use Google\Cloud\Datastore\V1\Mutation;
use Google\Cloud\Datastore\V1\PartitionId;
use Google\Cloud\Datastore\V1\PropertyMask;
use Google\Cloud\Datastore\V1\Query;
use Google\Cloud\Datastore\V1\ReadOptions;
use Google\Cloud\Datastore\V1\ReserveIdsRequest;
Expand Down Expand Up @@ -414,6 +415,13 @@ public function commit($projectId, $mode, $mutations, array $optionalArgs = [])
* database.
* @type ReadOptions $readOptions
* The options for this lookup request.
* @type PropertyMask $propertyMask
* The properties to return. Defaults to returning all properties.
*
* If this field is set and an entity has a property not referenced in the
* mask, it will be absent from [LookupResponse.found.entity.properties][].
*
* The entity's key is always returned.
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
Expand All @@ -440,6 +448,10 @@ public function lookup($projectId, $keys, array $optionalArgs = [])
$request->setReadOptions($optionalArgs['readOptions']);
}

if (isset($optionalArgs['propertyMask'])) {
$request->setPropertyMask($optionalArgs['propertyMask']);
}

$requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders);
$optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader();
return $this->startCall('Lookup', LookupResponse::class, $optionalArgs, $request)->wait();
Expand Down Expand Up @@ -669,6 +681,12 @@ public function runAggregationQuery($projectId, array $optionalArgs = [])
* The query to run.
* @type GqlQuery $gqlQuery
* The GQL query to run. This query must be a non-aggregation query.
* @type PropertyMask $propertyMask
* The properties to return.
* This field must not be set for a projection query.
*
* See
* [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
* @type ExplainOptions $explainOptions
* Optional. Explain options for the query. If set, additional query
* statistics will be returned. If not, only query results will be returned.
Expand Down Expand Up @@ -706,6 +724,10 @@ public function runQuery($projectId, $partitionId, array $optionalArgs = [])
$request->setGqlQuery($optionalArgs['gqlQuery']);
}

if (isset($optionalArgs['propertyMask'])) {
$request->setPropertyMask($optionalArgs['propertyMask']);
}

if (isset($optionalArgs['explainOptions'])) {
$request->setExplainOptions($optionalArgs['explainOptions']);
}
Expand Down
56 changes: 56 additions & 0 deletions Datastore/src/V1/LookupRequest.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions Datastore/src/V1/Mutation.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

96 changes: 96 additions & 0 deletions Datastore/src/V1/PropertyMask.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions Datastore/src/V1/RunQueryRequest.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading