Skip to content

fix(sqlite): support TimeField values - #2297

Merged
waketzheng merged 16 commits into
tortoise:developfrom
deeprave:feature/sqlite-timefield-support
Oct 29, 2026
Merged

waketzheng merged 16 commits into
tortoise:developfrom
deeprave:feature/sqlite-timefield-support

Conversation

@deeprave

@deeprave deeprave commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Description

Add SQLite DB-API adaptation for datetime.time, allowing TimeField values to be created, retrieved, and filtered.

Motivation and Context

SQLite currently rejects a bound datetime.time with sqlite3.ProgrammingError, despite Tortoise exposing TimeField and generating a TIME column. Fixes #2296.

How Has This Been Tested?

  • uv run pytest tests/fields/test_time.py -q
  • pre-commit run --files CHANGELOG.rst tortoise/backends/sqlite/executor.py tests/fields/test_time.py

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added the changelog accordingly.
  • I have read the CONTRIBUTING document. No CONTRIBUTING document is present in the repository.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copilot AI balanced review requested due to automatic review settings October 5, 2026 20:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The adapter integrates consistently with existing SQLite conversions and the new test covers the reported failure paths.

Review effort: Balanced
Findings: None

What changed in this PR

Adds SQLite support for persisting and querying TimeField values.

Changes:

  • Registers SQLite adaptation for datetime.time.
  • Adds create, retrieve, and filter coverage.
  • Documents the fix in the changelog.
File Description
tortoise/​backends/​sqlite/​executor.py Adds ISO-format time adaptation.
tests/​fields/​test_time.py Verifies SQLite time persistence and filtering.
CHANGELOG.rst Records the SQLite fix.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codspeed

codspeed Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 21 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 24 untouched benchmarks


Comparing deeprave:feature/sqlite-timefield-support (d57e0c8) with develop (7b43710)

Open in CodSpeed

Comment thread CHANGELOG.rst Outdated
@waketzheng
waketzheng merged commit 824e407 into tortoise:develop Oct 29, 2026
25 checks passed
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.

SQLite TimeField cannot be persisted

4 participants