Commit Graph

3 Commits

Author SHA1 Message Date
LearningCircuit
bab0f61b66 chore(hooks): require UtcDateTime in migrations too (#3523)
Tighten check-datetime-timezone so the UtcDateTime rule applies to
both models and migrations. Supersedes the inverted approach in #3515,
which tried to accept sa.DateTime(timezone=True) inside migrations.

- Rewrite the AST walker: handle sa.Column / bare Column, positional
  type arg at any index, bare Column(UtcDateTime) without parens (the
  hook's own example), and ast.IfExp with both branches inspected
  independently so a violation in either arm is still flagged.
- Anchor the path filter on src/local_deep_research/ to stop
  false-positives on tests/database/models/ and partial-name matches
  like database/models_backup/.
- Update .pre-commit-config.yaml name/description and the stale
  CI_CD_INFRASTRUCTURE.md hook table entry.
- Add tests/hooks/test_check_datetime_timezone.py with 20 cases:
  violations (models / migrations / conditional types / batch runs /
  bare names), allows (UtcDateTime with import, combo import order,
  empty / syntax-error files), and path-filter boundaries.
2026-04-18 21:47:17 +02:00
LearningCircuit
7c2f40cd44 fix: Use SQLAlchemy-UTC for proper timezone handling with SQLite
- Add sqlalchemy-utc package to handle timezone-aware datetimes
- Replace DateTime(timezone=True) with UtcDateTime in benchmark models
- Replace func.now() with utcnow() for proper UTC defaults
- Update pre-commit hook to enforce UtcDateTime usage
- Fixes timezone mismatch errors when SQLite returns naive datetimes

SQLite doesn't natively support timezone-aware datetimes, causing
issues when comparing timestamps. The sqlalchemy-utc package provides
a TypeDecorator that automatically converts between naive and aware
datetimes, ensuring consistent UTC handling across the application.
2025-08-06 20:35:07 +02:00
LearningCircuit
705a04ec79 fix: Add timezone support to DateTime columns and pre-commit hook
- Fixed timezone-aware/naive datetime subtraction error in benchmark
- Added timezone=True to all DateTime columns in benchmark models
- Created pre-commit hook to enforce timezone=True on DateTime columns
- Prevents future timezone-related bugs in database models
2025-08-06 00:16:47 +02:00