Commit c8ce8cf
committed
fix: consistent UTC timestamp handling for PostgreSQL in DatabaseSessionService
Fixes two timestamp inconsistencies that cause stale session detection
failures when using PostgreSQL with asyncpg:
1. append_event() now strips timezone info for PostgreSQL (matching
create_session() behavior). Previously, PostgreSQL got a local-time
naive datetime via datetime.fromtimestamp(), while create_session()
stored a UTC-based naive datetime. This mismatch caused
get_update_timestamp() to return incorrect values when the server
timezone differs from UTC.
2. get_update_timestamp() now uses tzinfo-awareness to decide whether
to interpret a naive datetime as UTC, rather than checking only for
SQLite. This correctly handles both SQLite and PostgreSQL naive
datetimes without requiring callers to pass dialect flags.
Fixes #4366
Related: #18481 parent ec660ed commit c8ce8cf
File tree
2 files changed
+18
-12
lines changed- src/google/adk/sessions
- schemas
2 files changed
+18
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
627 | 628 | | |
628 | 629 | | |
629 | 630 | | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
636 | 639 | | |
637 | 640 | | |
638 | 641 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
128 | 131 | | |
129 | 132 | | |
130 | 133 | | |
| |||
0 commit comments