Skip to content

Fix sa.Time() raising Cannot find data type: time on CrateDB#283

Merged
florinutz merged 4 commits into
mainfrom
fix/issue-206-sa-time
Jul 1, 2026
Merged

Fix sa.Time() raising Cannot find data type: time on CrateDB#283
florinutz merged 4 commits into
mainfrom
fix/issue-206-sa-time

Conversation

@florinutz

Copy link
Copy Markdown
Contributor

CrateTypeCompiler had no visit_time, so sa.Time fell through to SQLAlchemy's generic compiler and emitted SQL-standard TIME. CrateDB has no storable time-of-day type: plain TIME doesn't exist, and TIME WITH TIME ZONE (TIMETZ) is literal/cast-only ("does not support storage"). sa.Date/sa.DateTime worked only because they already had overrides mapping to TIMESTAMP.

Closes #206.

Fix

Storing time-of-day as a STRING in ISO 8601 format — the same convention the crate driver already uses for datetime.time (see crate/crate-python#696):

A datetime.time now round-trips intact, including tz-aware values.

Tests

  • tests/create_table_test.py: DDL renders STRING instead of TIME
  • tests/datetime_test.py: live round-trip of a datetime.time

@florinutz florinutz requested review from bgunebakan and kneth June 26, 2026 15:39
@florinutz florinutz self-assigned this Jun 26, 2026
@florinutz florinutz added bug Something isn't working python Pull requests that update Python code labels Jun 26, 2026
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 61dad7af-352e-4efb-b18b-31fa420c0756

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-206-sa-time

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread tests/create_table_test.py Fixed

@bgunebakan bgunebakan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you! I've added some comments.

Comment thread src/sqlalchemy_cratedb/dialect.py Outdated
Comment thread src/sqlalchemy_cratedb/compiler.py Outdated
Comment thread src/sqlalchemy_cratedb/dialect.py
@florinutz florinutz requested a review from bgunebakan June 30, 2026 12:19

@bgunebakan bgunebakan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you!

@florinutz florinutz merged commit b8d3cb7 into main Jul 1, 2026
27 checks passed
@florinutz florinutz deleted the fix/issue-206-sa-time branch July 1, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQLParseException[Cannot find data type: time]

4 participants