Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#519 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@JanJakes ci sta già lavorando.

Dal 6/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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.

Lingua principale
PHP
Stelle
362
Fork
67
Merge medio
1g 19h
PR unite (30g)
5

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

  • Nessun Dockerfile né file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di WordPress/sqlite-database-integration

Tutte le issue di WordPress/sqlite-database-integration

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.