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

Open Beginner friendly
#454 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
php, sqlite
Domain
databases

Research direction

Start in wp-includes/database/sqlite/class-wp-pdo-mysql-on-sqlite.php and trace how MySQL date arithmetic is translated before the SQLite query executes. Reproduce the SELECT using INTERVAL 5 HOUR, then verify that the generated SQLite datetime expression runs without a syntax error and supports the stated WordPress plugin query.

Written by the indexing model from the issue text.

Description

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.

Dominant language
PHP
Stars
363
Forks
67
Avg merge
2d 15h
Merged PRs (30d)
7

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from WordPress/sqlite-database-integration

All issues in WordPress/sqlite-database-integration

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.