Skip to content

Commit 5a2ca75

Browse files
authored
fix: use MySQL compatible syntax in list tasks (#651)
# Description Do not use `NULLS LAST` which is not available in MySQL, coalesce nulls to empty strings which will appear last in descending ordering (there are tests for this behavior already, however CI wasn't enabled for this branch). Currently `NULLS LAST` fails MySQL tests: ``` (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULLS LAST, tasks.id DESC \n LIMIT 51' at line 3") ``` ([actions run](https://github.com/a2aproject/a2a-python/actions/runs/21520017047/job/62008309612?pr=651)) Enable tests run against `1.0-dev` to prevent it in the future. Re #511 Fixes #652 --- Mark as "refactor" for release please as it's a fix for a non-released feature, hence shouldn't get into a changelog. BEGIN_COMMIT_OVERRIDE refactor: use MySQL compatible syntax in list tasks END_COMMIT_OVERRIDE
1 parent 044408f commit 5a2ca75

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Run Unit Tests
33
on:
44
pull_request:
5-
branches: [main]
5+
branches: [main, 1.0-dev]
66
permissions:
77
contents: read
88
jobs:

src/a2a/server/tasks/database_task_store.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,10 @@ async def list(
189189
count_stmt = select(func.count()).select_from(base_stmt.alias())
190190
total_count = (await session.execute(count_stmt)).scalar_one()
191191

192+
# Use coalesce to treat NULL timestamps as empty strings,
193+
# which sort last in descending order
192194
stmt = base_stmt.order_by(
193-
timestamp_col.desc().nulls_last(),
195+
func.coalesce(timestamp_col, '').desc(),
194196
self.task_model.id.desc(),
195197
)
196198

0 commit comments

Comments
 (0)