fix: parse since param to datetime for asyncpg compatibility
asyncpg requires datetime objects, not strings, for timestamptz params. Also use Z suffix in tests to avoid URL-encoding issues with +00:00.
This commit is contained in:
parent
0a4aed9e1b
commit
e08486f2bd
2 changed files with 5 additions and 4 deletions
|
|
@ -69,16 +69,17 @@ async def sync_memories(
|
||||||
|
|
||||||
async with pool.acquire() as conn:
|
async with pool.acquire() as conn:
|
||||||
if since:
|
if since:
|
||||||
|
since_dt = datetime.fromisoformat(since)
|
||||||
rows = await conn.fetch(
|
rows = await conn.fetch(
|
||||||
"""
|
"""
|
||||||
SELECT id, content, category, tags, expanded_keywords, importance,
|
SELECT id, content, category, tags, expanded_keywords, importance,
|
||||||
is_sensitive, created_at, updated_at, deleted_at
|
is_sensitive, created_at, updated_at, deleted_at
|
||||||
FROM memories
|
FROM memories
|
||||||
WHERE user_id = $1 AND updated_at > $2::timestamptz
|
WHERE user_id = $1 AND updated_at > $2
|
||||||
ORDER BY updated_at ASC
|
ORDER BY updated_at ASC
|
||||||
""",
|
""",
|
||||||
user.user_id,
|
user.user_id,
|
||||||
since,
|
since_dt,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
rows = await conn.fetch(
|
rows = await conn.fetch(
|
||||||
|
|
|
||||||
|
|
@ -349,7 +349,7 @@ async def test_sync_incremental_with_since(client):
|
||||||
|
|
||||||
async with ac:
|
async with ac:
|
||||||
resp = await ac.get(
|
resp = await ac.get(
|
||||||
"/api/memories/sync?since=2026-03-14T10:00:00+00:00",
|
"/api/memories/sync?since=2026-03-14T10:00:00Z",
|
||||||
headers={"Authorization": "Bearer test-key"},
|
headers={"Authorization": "Bearer test-key"},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -374,7 +374,7 @@ async def test_sync_includes_soft_deleted_with_since(client):
|
||||||
|
|
||||||
async with ac:
|
async with ac:
|
||||||
resp = await ac.get(
|
resp = await ac.get(
|
||||||
"/api/memories/sync?since=2026-03-14T10:00:00+00:00",
|
"/api/memories/sync?since=2026-03-14T10:00:00Z",
|
||||||
headers={"Authorization": "Bearer test-key"},
|
headers={"Authorization": "Bearer test-key"},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue