Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#519 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@JanJakes ya está trabajando en esto.

Desde el 6/10/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

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.

Lenguaje dominante
PHP
Estrellas
363
Forks
72
Merge medio
3 d 7 h
PR fusionados (30 d)
13

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

  • Sin Dockerfile ni archivo de Docker Compose
  • Sin plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de WordPress/sqlite-database-integration

Todos los issues de WordPress/sqlite-database-integration

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.