Skip to content

MySQL-on-SQLite does not translate DATE arithmetic with INTERVAL HOUR #454

Closed

Description

@chubes4

Bug

The current MySQL-on-SQLite driver leaves MySQL date arithmetic unchanged, causing SQLite syntax errors for queries such as:

SELECT DATE(start_datetime - INTERVAL 5 HOUR) FROM wp_event_dates;

The executed SQLite query still contains INTERVAL 5 HOUR and fails with:

SQLSTATE[HY000]: General error: 1 near \"5\": syntax error

Runtime

  • WordPress Playground / WP Codebox
  • WordPress 7.0.2
  • PHP 8.3.31
  • SQLite integration path: wp-includes/database/sqlite/class-wp-pdo-mysql-on-sqlite.php

Expected

Translate MySQL INTERVAL ... HOUR date arithmetic to an equivalent SQLite datetime modifier so valid WordPress plugin queries can execute under the compatibility layer.

Impact

This blocks focused WordPress PHPUnit coverage for timezone-aware calendar boundaries in Extra-Chill/data-machine-events#489 after its custom test table is successfully created.

Activity

  1. JanJakes commented on Jul 27, 2026

    @JanJakes
    Member

    @chubes4 Something's wrong with the formatting; could you please take a look?

    Image
  2. chubes4 commented on Jul 27, 2026

    @chubes4
    ContributorAuthor

    Fixed, thanks for the heads-up.

  3. samuelmbabhazi commented on Sep 20, 2026

    @samuelmbabhazi
    Contributor

    I can take this one. The parser already accepts the infix form; the translator just passes it through. Both the suffix form (expr - INTERVAL n unit) and the prefix form (INTERVAL n unit + expr) can reuse the DATETIME() translation that DATE_ADD and DATE_SUB use, and the same change closes #90. I will open a PR unless someone is on it.

  4. added a commit that references this issue on Sep 20, 2026
    dccd7b2
  5. added 2 commits that reference this issue on Oct 19, 2026
    5fba709
    5b2a951
  6. added a commit that references this issue on Oct 21, 2026
    0996313
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions