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

Enhance Commit API readability #7296

Closed
wants to merge 39 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0baef28
feat!: [Datastore] Upgrade to PHP v2
yash30201 Mar 26, 2024
7215b2e
Enable Gapic Client support for Request Handler.
yash30201 Mar 26, 2024
237531f
Add credentials wrapper support in DatastoreClient
yash30201 Mar 26, 2024
cac76f1
Add request handler and serializer in DatastoreClient
yash30201 Mar 26, 2024
f39189f
Update Resource classes to add serializer and requesthandler in their…
yash30201 Mar 26, 2024
be2533c
Update snippet and unit tests to add request handler and serializer.
yash30201 Mar 26, 2024
d06abf7
Update beginTransaction and allocateIds rpc + unit + snippet tests
yash30201 Mar 31, 2024
cee1539
Update lookup rpc + unit + snippet tests
yash30201 Apr 1, 2024
927d510
Update RunQuery rpc + unit + snippet tests
yash30201 Apr 3, 2024
c9d2186
Update RunAggregationQuery rpc + unit + snippet tests
yash30201 Apr 3, 2024
82716bd
Update Commit rpc + unit + snippet tests
yash30201 Apr 3, 2024
fcdcf9b
Update Rollback rpc + unit + snippet tests
yash30201 Apr 3, 2024
4c32fc9
Remove all connection classes and references
yash30201 Apr 3, 2024
0596f27
Remove old gapic files and class aliases
yash30201 Apr 4, 2024
fa9e30a
Fix unit test failures
yash30201 Apr 4, 2024
e6fa30a
Fix PHP style checks
yash30201 Apr 4, 2024
2d01ea6
Fix aggregation query snippet test
yash30201 Apr 4, 2024
e098d66
Add MIGRATION.md
yash30201 Apr 4, 2024
2196aa2
Update documentation for DatastoreClient
yash30201 Apr 4, 2024
bf2c50b
Increase minimum core version to 1.55
yash30201 Apr 4, 2024
d6e2823
Mark `Operation` as internal
yash30201 Apr 4, 2024
6a03125
Merge branch 'main' into datastore-php-v2
yash30201 Apr 4, 2024
af549dd
Increase minimum core version to 1.57 (to be version)
yash30201 Apr 4, 2024
170d590
Fix emulator tests
yash30201 Apr 5, 2024
8e43aab
Self iteration
yash30201 Apr 5, 2024
9cf8493
Merge branch 'main' into datastore-php-v2
yash30201 May 6, 2024
fad4022
Iteration 1
yash30201 May 6, 2024
d45178c
fix(Spanner):Properly remove redundant keys from request options
yash30201 May 7, 2024
14fc795
pr iteration
yash30201 May 7, 2024
b9f0661
Add comments
yash30201 May 7, 2024
c6275bd
fix(Datastore):Properly remove redundant keys from request options
yash30201 May 7, 2024
81655e1
chore(Datastore): Update Composer version to use the upcoming latest.
yash30201 May 7, 2024
7e1dfa3
chore(Datastore): Update Composer version to use the upcoming latest.
yash30201 May 7, 2024
8c5a721
Merge branch 'main' into datastore-tryout-1
yash30201 May 7, 2024
b49d34e
Merge branch 'main' into datastore-php-v2
yash30201 May 7, 2024
2f33be4
Merge branch 'datastore-php-v2' of https://github.com/yash30201/googl…
yash30201 May 7, 2024
4c29341
chore(Datastore): Enhance readability of RunQuery and RunAggregationQ…
yash30201 May 7, 2024
dd24b76
Merge branch 'datastore-php-v2' into datastore-tryout-1
yash30201 May 7, 2024
ab08e92
Enhance Commit API readability
yash30201 May 7, 2024
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
Prev Previous commit
Next Next commit
Fix PHP style checks
yash30201 committed Apr 4, 2024
commit e6fa30a368503b12df258329f956c80779db15c4
18 changes: 12 additions & 6 deletions Datastore/src/Operation.php
Original file line number Diff line number Diff line change
@@ -459,7 +459,13 @@ public function lookup(array $keys, array $options = [])
$serviceKeys[] = $key->keyObject();
});

list($data, $optionalArgs) = $this->splitOptionalArgs($options, ['transaction', 'className', 'sort', 'readTime', 'readConsistency']);
list($data, $optionalArgs) = $this->splitOptionalArgs($options, [
'transaction',
'className',
'sort',
'readTime',
'readConsistency'
]);
$data += $this->readOptions($options) + [
'projectId' => $this->projectId,
'databaseId' => $this->databaseId,
@@ -748,15 +754,15 @@ public function commit(array $mutations, array $options = [])
$data = $mutation[$mutationType];
if (isset($data['properties'])) {
foreach ($data['properties'] as &$property) {
list ($type, $val) = $this->toGrpcValue($property);
list($type, $val) = $this->toGrpcValue($property);

$property[$type] = $val;
}
}

$mutation[$mutationType] = $data;

$mutation = $this->serializer->decodeMessage(new Mutation, $mutation);
$mutation = $this->serializer->decodeMessage(new Mutation(), $mutation);
}

$options += [
@@ -1104,7 +1110,7 @@ private function parseQuery(array $query)
}

$parsedQuery = $this->serializer->decodeMessage(
new V1Query,
new V1Query(),
$query
);
return $parsedQuery;
@@ -1139,7 +1145,7 @@ private function parseGqlQuery(array $gqlQuery)
}

$parsedGqlQuery = $this->serializer->decodeMessage(
new GqlQuery,
new GqlQuery(),
$gqlQuery
);

@@ -1198,7 +1204,7 @@ private function prepareQueryBinding(array $binding)
{
$value = $binding['value'];

list ($type, $val) = $this->toGrpcValue($value);
list($type, $val) = $this->toGrpcValue($value);

$binding['value'][$type] = $val;

12 changes: 6 additions & 6 deletions Datastore/tests/Snippet/ReadOnlyTransactionTest.php
Original file line number Diff line number Diff line change
@@ -104,7 +104,7 @@ public function testClass()
0
);

$this->refreshOperation($this->client,$this->requestHandler->reveal(), [
$this->refreshOperation($this->client, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -134,7 +134,7 @@ public function testClassRollback()

$snippet = $this->snippetFromClass(ReadOnlyTransaction::class, 1);

$this->refreshOperation($this->client,$this->requestHandler->reveal(), [
$this->refreshOperation($this->client, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -175,7 +175,7 @@ public function testLookup()
]
);

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -226,7 +226,7 @@ public function testLookupBatch()
]
);

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -272,7 +272,7 @@ public function testRunQuery()
0
);

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -287,7 +287,7 @@ public function testRollback()

$this->mockSendRequest('rollback', [], [], 0);

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

24 changes: 12 additions & 12 deletions Datastore/tests/Snippet/TransactionTest.php
Original file line number Diff line number Diff line change
@@ -108,7 +108,7 @@ public function testClass()
0
);

$this->refreshOperation($this->client,$this->requestHandler->reveal(), [
$this->refreshOperation($this->client, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -132,7 +132,7 @@ public function testInsert()
]
]);

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -153,7 +153,7 @@ public function testInsertBatch()

$this->allocateIdsRequestHandlerMock();

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -175,7 +175,7 @@ public function testUpdate()
]
]);

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -212,7 +212,7 @@ public function testUpsert()
]
]);

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -246,7 +246,7 @@ public function testDelete()
]
]);

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -293,7 +293,7 @@ public function testLookup()
]
);

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -344,7 +344,7 @@ public function testLookupBatch()
]
);

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -390,7 +390,7 @@ public function testRunQuery()
0
);

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -426,7 +426,7 @@ public function testRunAggregationQuery()
0
);

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -441,7 +441,7 @@ public function testCommit()

$this->mockSendRequest('commit', [], [], 0);

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -455,7 +455,7 @@ public function testRollback()

$this->mockSendRequest('rollback', [], [], 0);

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

6 changes: 4 additions & 2 deletions Datastore/tests/Unit/OperationTest.php
Original file line number Diff line number Diff line change
@@ -666,7 +666,9 @@ public function testRunQueryWithoutReadOptions()
$this->requestHandler->sendRequest(
DatastoreClient::class,
'runQuery',
Argument::that(function ($req) {return !$req->hasReadOptions();}),
Argument::that(function ($req) {
return !$req->hasReadOptions();
}),
Argument::cetera()
)->willReturn([])->shouldBeCalled();

@@ -862,7 +864,7 @@ public function testMutateWithKey()
$this->requestHandler->sendRequest(
DatastoreClient::class,
'commit',
Argument::that(function ($arg) use ($otherThis){
Argument::that(function ($arg) use ($otherThis) {
$data = $otherThis->serializer->encodeMessage($arg);
$x = isset($data['mutations'][0]['delete']['path']);
return isset($data['mutations'][0]['delete']['path']);
28 changes: 14 additions & 14 deletions Datastore/tests/Unit/TransactionTest.php
Original file line number Diff line number Diff line change
@@ -123,7 +123,7 @@ public function testLookup(callable $transaction)
);

$transaction = $transaction();
$this->refreshOperation($transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -151,7 +151,7 @@ public function testLookupMissing(callable $transaction)
);

$transaction = $transaction();
$this->refreshOperation($transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -186,7 +186,7 @@ public function testLookupBatch(callable $transaction)
);

$transaction = $transaction();
$this->refreshOperation($transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -216,7 +216,7 @@ public function testLookupBatchWithReadTime(callable $transaction)
);

$transaction = $transaction();
$this->refreshOperation($transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -247,7 +247,7 @@ public function testRunQuery(callable $transaction)
);

$transaction = $transaction();
$this->refreshOperation($transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -284,7 +284,7 @@ public function testRunAggregationQuery(callable $transaction)
);

$transaction = $transaction();
$this->refreshOperation($transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -323,7 +323,7 @@ public function testRunQueryWithReadTime()
);

$transaction = $this->readOnly;
$this->refreshOperation($transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -343,7 +343,7 @@ public function testRollback(callable $transaction)
$this->mockSendRequest('rollback', ['transaction' => self::TRANSACTION], [], 0);

$transaction = $transaction();
$this->refreshOperation($transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -366,7 +366,7 @@ public function testEntityMutations($method, $mutation, $key)
0
);

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -392,7 +392,7 @@ public function testEntityMutationsBatch($method, $mutation, $key)
0
);

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -433,7 +433,7 @@ public function testMutationsWithPartialKey($method, $mutation, $key, $id)
['keys' => [$keyWithId->keyObject()]]
);

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -468,7 +468,7 @@ public function testBatchMutationsWithPartialKey($method, $mutation, $key, $id)
['keys' => [$keyWithId->keyObject()]]
);

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -501,7 +501,7 @@ public function testDelete()
0
);

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

@@ -525,7 +525,7 @@ public function testDeleteBatch()
0
);

$this->refreshOperation($this->transaction,$this->requestHandler->reveal(), [
$this->refreshOperation($this->transaction, $this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);