Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: use MySQL compatible syntax in list tasks - #651

Merged
ishymko merged 4 commits into
1.0-devfrom
ishymko/1.0-tests
Feb 2, 2026
Merged

ishymko merged 4 commits into
1.0-devfrom
ishymko/1.0-tests

Conversation

@ishymko

@ishymko ishymko commented Jan 30, 2026

Copy link
Copy Markdown
Member

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)

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

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

@ishymko ishymko closed this Jan 30, 2026
@ishymko ishymko reopened this Jan 30, 2026
@ishymko
ishymko changed the base branch from 1.0-dev to ishymko/tests-base January 30, 2026 15:23
@ishymko ishymko mentioned this pull request Jan 30, 2026
1 task
Based on
[`unit-tests.yml`](https://github.com/a2aproject/a2a-python/blob/main/.github/workflows/unit-tests.yml).

Supports:
- `--debug` to start DB(s) without running tests (for selective running
in IDE)
- `--mysql`, `--postgres` to use only one DB
- `--stop` to stop after running with `--debug`

From project root:

```bash
./scripts/run_integration_tests.sh
```

Re #652 to troubleshoot failures
@ishymko
ishymko changed the base branch from ishymko/tests-base to 1.0-dev February 2, 2026 07:57
@ishymko ishymko changed the title ci: run tests and linter on 1.0-dev fix: use MySQL compatible ordering for listing tasks Feb 2, 2026
This reverts commit 9dad851127995fb92860febef7deadc0ad79e294.
@ishymko ishymko changed the title fix: use MySQL compatible ordering for listing tasks fix: use MySQL compatible syntax in list tasks Feb 2, 2026
@ishymko
ishymko marked this pull request as ready for review February 2, 2026 08:04
@ishymko
ishymko requested a review from a team as a code owner February 2, 2026 08:04
@ishymko
ishymko requested a review from guglielmo-san February 2, 2026 08:06
@ishymko
ishymko merged commit 5a2ca75 into 1.0-dev Feb 2, 2026
14 checks passed
@ishymko
ishymko deleted the ishymko/1.0-tests branch February 2, 2026 08:20
ishymko added a commit that referenced this pull request Feb 13, 2026
# 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
mykytanetipa added a commit that referenced this pull request Sep 10, 2026
# Description

`DatabaseTaskStore.list()` currently makes NULL timestamps sort last by
coalescing them to `datetime.min` (year 0001). MySQL documents year 1000
as the
lower bound of its supported `DATETIME` range. Current MySQL versions
may still
accept year 0001, so this is a portability and specification-conformance
risk
rather than a consistently reproducible runtime failure.

This change replaces the datetime sentinel with an explicit ordering
key:

1. a `CASE` expression ranks non-NULL timestamps before NULL timestamps;
2. non-NULL timestamps remain in descending order; and
3. task IDs remain the descending tie-breaker, including for NULL
timestamps.

This preserves the existing list and cursor-pagination order without
binding an
out-of-range datetime. It also avoids `NULLS LAST`, which MySQL does not
support
and which was previously removed in #651.

The regression test observes SQLAlchemy's compiled execution parameters
and
fails if `list()` binds a datetime before year 1000. With the test
applied to the
base implementation, the SQLite case failed by capturing the year-0001
sentinel. With this change, the same test passes on SQLite, PostgreSQL
15, and
MySQL 8.0, alongside the existing ordering and pagination matrix.

## Validation

- `./scripts/lint.sh` — Ruff check/format passed; `ty check` passed
- `./scripts/run_db_tests.sh -k test_list_tasks` — 36 passed across
SQLite,
  PostgreSQL 15, and MySQL 8.0
- `uv run pytest
tests/integration/cross_version/client_server/test_client_server.py -q`
  — 4 passed
- `uv run pytest` — 1971 passed, 92 skipped, 3 xfailed, 1 xpassed
- `uv run pytest --cov=src --cov-report=term-missing` — same test
result,
  93% total coverage
- `git diff --check` — passed

## Checklist

- [x] Followed the `CONTRIBUTING` guide and repository AI workflow
documents.
- [x] Used a Conventional Commit title.
- [x] Ran the required linter, formatter, type checker, full tests, and
coverage.
- [x] Added a regression test for the changed runtime behavior.
- [x] No user-facing documentation change is required; ordering
semantics are
      unchanged.

Fixes #1219 🦕

AI assistance was used for issue and code-path research and for
drafting. I
reviewed the final diff and ran every validation command listed above.

Co-authored-by: mykytanetipa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants