Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#9,811 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php
Ambito
backend, databases

Direzione di ricerca

Inizia da Spanner/src/Operation.php, intorno alle righe 103–109, e confronta le chiamate a validateOptions() in quel file. L’issue indica la modifica alla destrutturazione e le opzioni interessate; controlla i test Spanner esistenti per le opzioni a livello client e aggiungi test per returnInt64AsObject e defaultQueryOptions. Il lavoro è completato quando le opzioni del costruttore hanno effetto e i test pertinenti passano.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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)
Lingua principale
PHP
Stelle
1.2k
Fork
466
Merge medio
2g 12h
PR unite (30g)
50

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di googleapis/google-cloud-php

Tutte le issue di googleapis/google-cloud-php

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.