[Spanner] v2: client-level queryOptions passed to SpannerClient are silently ignored
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Start with Spanner/src/Operation.php around lines 103–109 and compare the validateOptions() calls in that file. The issue identifies the destructuring change and the affected options; check existing Spanner tests for client level options and add coverage for returnInt64AsObject and defaultQueryOptions. Done when constructor options take effect and the relevant tests pass.
Written by the indexing model from the issue text.
Description
In v2, queryOptions and returnInt64AsObject passed to SpannerClient have no effect, even though both are documented constructor options. Query-level queryOptions and the SPANNER_OPTIMIZER_* environment variables still work.
The options do reach Operation, but its constructor doesn't destructure the result of validateOptions() (Operation.php#L103-L109):
$options = $this->validateOptions(
$options,
['returnInt64AsObject', 'routeToLeader', 'defaultQueryOptions']
);
// $options is [[...]] here, so all three fall back to their defaults
$this->mapper = new ValueMapper($options['returnInt64AsObject'] ?? false);
$this->routeToLeader = $options['routeToLeader'] ?? true;
$this->defaultQueryOptions = $options['defaultQueryOptions'] ?? [];
Changing this to [$options] = $this->validateOptions(...), matching the other calls in Operation.php, fixes the issue.
This looks like a regression from the v2 rewrite (#7841). In v1, client-level query options were applied in Connection\Grpc and tested in GrpcTest. Both were removed with the Connection layer.
Environment details
- OS: Alpine Linux (Docker) + Spanner emulator
- PHP version: 8.4.16
- Package name and version: google/cloud-spanner v2.11.3
Steps to reproduce
- Create a
SpannerClientwithreturnInt64AsObject => true. - Run a query that returns an INT64.
Code example
<?php
// SPANNER_EMULATOR_HOST=localhost:9010 php repro.php
require 'vendor/autoload.php';
use Google\Cloud\Spanner\SpannerClient;
$client = new SpannerClient([
'projectId' => 'emulator-project',
'returnInt64AsObject' => true,
]);
$database = $client->connect('test-instance', 'test-database');
var_dump($database->execute('SELECT 1 AS x')->rows()->current()['x']);
// Expected: object(Google\Cloud\Core\Int64)
// Actual: int(1)
- Dominant language
- PHP
- Stars
- 1.2k
- Forks
- 466
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 40
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from googleapis/google-cloud-php
-
[Gax] RetryMiddleware keeps a reference to itself since v1.43.1, leaking the handler chain and its sockets in long-running processesPossibly taken @Hectorhammett claimed this 21 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
googleapis/google-cloud-php#9813 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
Consider clarifying which RFCs are supportedPossibly taken @bshaffer claimed this 14 days ago. Opentype: feature request
Difficulty 1/5 Under an hour Newbie friendliness 75/100
googleapis/google-cloud-php#9716 · 11 reactions ·
Maintainers usually reply within 1 day
-
eMudhra/emSign CA compromise (October 2026): what Cloud SDK PHP Libraries developers need to doOpen
Difficulty 1/5 Under an hour Newbie friendliness 8/100
googleapis/google-cloud-php#9844 ·
Maintainers usually reply within 1 day
-
Release verification failedPossibly taken @bshaffer claimed this 13 days ago. Open:rotating_light: critical
googleapis/google-cloud-php#9838 · 12 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
[firebase/php-jwt] Support ML-DSA signing algorithmsPossibly taken @bshaffer claimed this 36 days ago. Open
Difficulty 5/5 Over a week Newbie friendliness 35/100
googleapis/google-cloud-php#9777 · 4 comments · 2 reactions · 1 assignee ·
Maintainers usually reply within 1 day
All issues in googleapis/google-cloud-php
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 89/100
backdrop-contrib/commerce#65 ·
-
backend enhancement good first issue php
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
enhancement good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Evalogical-Inc/devReady#66 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
mollie/PrestaShop#1627 ·
Maintainers usually reply within 5 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
FriendsOfFlarum/follow-tags#118 ·