Content-Length: 328600 | pFad | http://github.com/chemelnucfin/google-cloud-python/commit/19097f45f421e26e32567c5a48305a3a9d96bd37

E9 Spanner: Fix database not found error, Closes #4071 · chemelnucfin/google-cloud-python@19097f4 · GitHub
Skip to content

Commit 19097f4

Browse files
committed
Spanner: Fix database not found error, Closes googleapis#4071
1 parent c09950b commit 19097f4

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

spanner/google/cloud/spanner_v1/database.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ def create(self):
211211
if exc_to_code(exc.cause) == StatusCode.ALREADY_EXISTS:
212212
raise Conflict(self.name)
213213
elif exc_to_code(exc.cause) == StatusCode.NOT_FOUND:
214-
raise NotFound('Instance not found: {name}'.format(
215-
name=self._instance.name,
214+
raise NotFound('Database not found: {name}'.format(
215+
name=db_name,
216216
))
217217
raise
218218

spanner/tests/system/test_system.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
from google.cloud._helpers import UTC
3838
from google.cloud.exceptions import GrpcRendezvous
39+
from google.cloud.exceptions import NotFound
3940
from google.cloud.spanner_v1._helpers import TimestampWithNanoseconds
4041
from google.cloud.spanner import Client
4142
from google.cloud.spanner import KeyRange
@@ -285,6 +286,18 @@ def test_create_database(self):
285286
for database in Config.INSTANCE.list_databases()]
286287
self.assertIn(temp_db_id, database_ids)
287288

289+
def test_create_database_not_found(self):
290+
temp_db_id = 'temp_db' + unique_resource_id('_')
291+
temp_db = Config.INSTANCE.database("bitemporal_pattern1", ddl_statements=[
292+
"""CREATE TABLE MyTable (
293+
Id String(36) NOT NULL,
294+
Field1 STRING(36) NOT NULL
295+
) PRIMARY KEY (Id)""",
296+
"""CREATE INDEX IDX ON yTable (Field1)"""
297+
])
298+
with self.assertRaisesRegexp(NotFound, "Database not found"):
299+
operation = temp_db.create()
300+
288301
def test_update_database_ddl(self):
289302
pool = BurstyPool()
290303
temp_db_id = 'temp_db' + unique_resource_id('_')

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/chemelnucfin/google-cloud-python/commit/19097f45f421e26e32567c5a48305a3a9d96bd37

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy