Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Match MySQL mixed-type result and comparison semantics for IF(), CASE, and IFNULL()

オープン
#519 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@JanJakes がすでに取り組んでいます。

2026年10月6日 から。

評価

この issue はまだ評価されていません。

説明

Summary

Implement MySQL-compatible mixed-type result conversion and comparison semantics for IF(), CASE, and IFNULL().

This is a pre-existing compatibility gap, separate from the IF() condition-evaluation bug in #517. Keep #518 focused on that bug. Build this follow-up on the comparison work in #508.

Reproduction and rationale

SELECT IF(1, 2, '3') = '2';

MySQL returns 1. The raw SQLite translation returns 0:

SELECT CASE WHEN 1 THEN 2 ELSE '3' END = '2';

SQLite preserves the selected branch's integer storage class. MySQL applies result-type rules across the branches. Related mixed-type conversion gaps affect CASE and IFNULL().

An unconditional text cast can fix this example but break numeric comparisons. The solution must account for both result-type rules and the surrounding comparison semantics.

Required changes

  • Determine MySQL result-type and comparison rules for mixed numeric, string, and NULL values in IF(), CASE, and IFNULL().
  • Extend the translator and comparison handling from #508 to reproduce those rules consistently.
  • Preserve lazy evaluation of unselected branches and fallback expressions.
  • Add regression tests against MySQL reference results for string comparisons, numeric comparisons, NULLs, nested expressions, and column-derived values.
  • Avoid an unconditional text cast as the general solution.

Affected areas

  • packages/mysql-on-sqlite/src/sqlite/class-wp-mysql-on-sqlite.php: translate_runtime_function_call(), expression translation, and comparison handling.
  • packages/mysql-on-sqlite/tests/WP_MySQL_On_SQLite_Tests.php: regression coverage for IF(), CASE, and IFNULL().

Acceptance criteria

  • SELECT IF(1, 2, '3') = '2' returns 1, matching MySQL.
  • Mixed-type string and numeric comparison cases for all three constructs match MySQL reference results.
  • NULL handling and lazy evaluation remain correct.
  • Existing IF() condition-evaluation and comparison tests continue to pass.

Context

Requested by @JanJakes.

主要言語
PHP
スター
362
フォーク
67
平均マージ
1日 19時間
マージ済み PR(30日)
5

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

WordPress/sqlite-database-integration のほかの issue

WordPress/sqlite-database-integration の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。