Closed oprudkyi closed 1 year ago
Hi @oprudkyi I tried the following code snippet:
$instanceId = "";
$databaseId = "";
$spanner = new SpannerClient();
$instance = $spanner->instance($instanceId);
$database = $instance->database($databaseId);
if (!$database->exists()) {
throw new \LogicException("Database $databaseId does not exist");
}
The line $database = $instance->database($databaseId);
doesn't throw an exception on using an incorrect database id.
Can you share the code snippet that you used?
Hi @saranshdhingra
I am using https://github.com/colopl/laravel-spanner basically you have to use CacheSessionPool and Database->runTransaction to get this error
something like
use Google\Cloud\Spanner\SpannerClient;
use Google\Cloud\Spanner\Session\CacheSessionPool;
use Google\Auth\Cache\SysVCacheItemPool;
use Google\Cloud\Spanner\Transaction;
$cache = new SysVCacheItemPool();
$sessionPool = new CacheSessionPool($cache, ['maxSessions' => 100]);
$spanner = new SpannerClient([ 'projectId' => 'project' ]);
$connection = $spanner->connect("instance", "database", ['sessionPool' => $sessionPool]);
$connection->runTransaction(function (Transaction $t) {
$t->select("SELECT 1");
$t->commit();
});
Seems like this was fixed?
Yes, we should close this!
Steps to reproduce
When I am trying to access non-existent db there is an error
probably existence (accessibility) of project/instance/db should be checked somehow before or at least error message should include project/instance/db to simplify debugging
moved from https://github.com/colopl/laravel-spanner/issues/40