Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 67f5104

Browse filesBrowse files
authored
fix(spanner): restore implicit database_dialect reload in sync client (#1537)
**Problem** Following the introduction of AsyncIO support via CrossSync, code generation for the synchronous client caused a regression in Database.database_dialect. Previously, if the property was accessed and returned DATABASE_DIALECT_UNSPECIFIED, the client would implicitly make a blocking self.reload() to retrieve the dialect from the server. This was lost during the shift to CrossSync as properties cannot be asynchronous in the _async source of truth. **Solution** Restore the lazy-loading reload behavior via an environment check: __async/database.py_: Added if not CrossSync.is_async: guard directly into the database_dialect getter. This makes it un-reachable code in the async runtime (where blocking properties or un-awaited coroutines are frowned upon). _database.py_: The generator strips the CrossSync context into a standard synchronous self.reload() call, successfully maintaining strict backwards compatibility for all existing synchronous libraries.
1 parent 3909c04 commit 67f5104
Copy full SHA for 67f5104

2 files changed

+5Lines changed: 5 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/google-cloud-spanner/google/cloud/spanner_v1/_async/database.py‎

Copy file name to clipboardExpand all lines: packages/google-cloud-spanner/google/cloud/spanner_v1/_async/database.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,9 @@ def database_dialect(self):
410410
:rtype: :class:`google.cloud.spanner_admin_database_v1.types.DatabaseDialect`
411411
:returns: the dialect of the database
412412
"""
413+
if self._database_dialect == DatabaseDialect.DATABASE_DIALECT_UNSPECIFIED:
414+
if not CrossSync.is_async:
415+
self.reload()
413416
return self._database_dialect
414417

415418
@property
Collapse file

‎packages/google-cloud-spanner/google/cloud/spanner_v1/database.py‎

Copy file name to clipboardExpand all lines: packages/google-cloud-spanner/google/cloud/spanner_v1/database.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ def database_dialect(self):
358358
359359
:rtype: :class:`google.cloud.spanner_admin_database_v1.types.DatabaseDialect`
360360
:returns: the dialect of the database"""
361+
if self._database_dialect == DatabaseDialect.DATABASE_DIALECT_UNSPECIFIED:
362+
self.reload()
361363
return self._database_dialect
362364

363365
@property

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.