Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[Spanner] v2: client-level queryOptions passed to SpannerClient are silently ignored

オープン 初心者向け
#9,811 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php
領域
backend, databases

調査の方向性

Spanner/src/Operation.phpの103~109行付近から始め、そのファイル内のvalidateOptions()の呼び出しを比較してください。Issueでは、分割代入の変更と影響を受けるオプションが示されています。クライアントレベルのオプションに関する既存のSpannerテストを確認し、returnInt64AsObjectとdefaultQueryOptionsのテストを追加してください。コンストラクターのオプションが反映され、関連するテストが通れば完了です。

索引モデルが issue の本文から書いたものです。

説明

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
  1. Create a SpannerClient with returnInt64AsObject => true.
  2. 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)
主要言語
PHP
スター
1.2k
フォーク
466
平均マージ
3日 3時間
マージ済み PR(30日)
49

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

googleapis/google-cloud-php のほかの issue

googleapis/google-cloud-php の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。