Commit 46ce908
authored
fix timezones in threads (#11498)
## Description
Fix thread timestamps being returned in incorrect timezone from
`listThreadsByResourceId`.
The `listThreadsByResourceId` method was not selecting or using the
timezone-aware columns (`createdAtZ`/`updatedAtZ` which are
`TIMESTAMPTZ` type). This caused timestamps to be read from the
`TIMESTAMP WITHOUT TIME ZONE` columns and interpreted in local timezone
instead of UTC.
The fix updates `listThreadsByResourceId` to:
1. Select the timezone-aware columns (`createdAtZ`, `updatedAtZ`)
2. Use them with fallback for legacy data (matching the pattern already
used in `getThreadById`)
## Related Issue(s)
#11496
## Type of Change
- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Code refactoring
- [ ] Performance improvement
- [x] Test update
## Checklist
- [x] I have made corresponding changes to the documentation (if
applicable)
- [x] I have added tests that prove my fix is effective or that my
feature works
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Patched @mastra/pg to fix thread timestamp handling by implementing
timezone-aware timestamp columns with automatic fallback support for
legacy data, ensuring consistent timestamp values across operations
* **Tests**
* Added comprehensive test to verify timestamp consistency across thread
retrieval operations, confirming that created and updated timestamps
remain synchronized across different data access methods
<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent c042bd0 commit 46ce908
File tree
3 files changed
+60
-5
lines changed- .changeset
- stores
- _test-utils/src/domains/memory
- pg/src/storage/domains/memory
3 files changed
+60
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
106 | 147 | | |
107 | 148 | | |
108 | 149 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | | - | |
243 | | - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
244 | 248 | | |
245 | 249 | | |
246 | | - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
247 | 253 | | |
248 | | - | |
249 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
250 | 257 | | |
251 | 258 | | |
252 | 259 | | |
| |||
0 commit comments