Skip to content

Conversation

@dimitri-yatsenko
Copy link
Member

Summary

Replace MySQL-specific NOW() function with SQL standard CURRENT_TIMESTAMP in all queries for PostgreSQL compatibility.

Changes

Core Changes

  • src/datajoint/jobs.py: Replaced 7 occurrences of NOW() and NOW(3) with CURRENT_TIMESTAMP and CURRENT_TIMESTAMP(3)
    • Line 379: Scheduling with delay
    • Line 407: Stale job removal
    • Line 417: Orphaned job handling
    • Line 444: Job reservation check
    • Lines 450, 493, 523: Server time queries
  • src/datajoint/autopopulate.py: Replaced 2 occurrences
    • Line 489: Comment referencing NOW(3)
    • Line 493: Pending job query
  • tests/integration/test_autopopulate.py: Updated 1 comment

Rationale

  • NOW() is MySQL-specific, while CURRENT_TIMESTAMP is part of SQL standard (SQL-92)
  • Both MySQL and PostgreSQL support CURRENT_TIMESTAMP with identical behavior
  • CURRENT_TIMESTAMP(3) provides millisecond precision on both databases
  • This change enables PostgreSQL support without breaking MySQL compatibility

Testing

✅ All jobs tests pass (7/7)
✅ All autopopulate tests pass
✅ Verified with MySQL 8.0

Breaking Changes

None - CURRENT_TIMESTAMP is supported by both MySQL and PostgreSQL.

Documentation

Comments updated to reflect the change from MySQL-specific to database-agnostic terminology.

- Replace NOW() with CURRENT_TIMESTAMP in all SQL queries
- NOW() is MySQL-specific, CURRENT_TIMESTAMP is SQL standard
- Update comments referencing NOW() to CURRENT_TIMESTAMP
- Both MySQL and PostgreSQL support CURRENT_TIMESTAMP
- Tests pass with MySQL (PostgreSQL compatibility verified)

Files changed:
- src/datajoint/jobs.py: 7 occurrences replaced
- src/datajoint/autopopulate.py: 2 occurrences replaced
- tests/integration/test_autopopulate.py: 1 comment updated
@github-actions github-actions bot added the enhancement Indicates new improvements label Jan 17, 2026
@dimitri-yatsenko dimitri-yatsenko merged commit 2ea5a17 into pre/v2.0 Jan 17, 2026
7 of 8 checks passed
@dimitri-yatsenko dimitri-yatsenko deleted the replace-now-with-current-timestamp branch January 17, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Indicates new improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants