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 67f5104
File tree
2 files changed
+5
-0
lines changed- packages/google-cloud-spanner/google/cloud/spanner_v1
- _async
2 files changed
+5
-0
lines changedLines 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 | | |
| |||
Lines 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