Commit 67f5104
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 67f5104Copy 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
- packages/google-cloud-spanner/google/cloud/spanner_v1
- _async
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 number | Diff line number | Diff line change |
|---|---|---|
| ||
410 | 410 | |
411 | 411 | |
412 | 412 | |
| 413 | + |
| 414 | + |
| 415 | + |
413 | 416 | |
414 | 417 | |
415 | 418 | |
|
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 number | Diff line number | Diff line change |
|---|---|---|
| ||
358 | 358 | |
359 | 359 | |
360 | 360 | |
| 361 | + |
| 362 | + |
361 | 363 | |
362 | 364 | |
363 | 365 | |
|
0 commit comments