Match MySQL mixed-type result and comparison semantics for IF(), CASE, and IFNULL()
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, andIFNULL(). - 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 forIF(),CASE, andIFNULL().
Acceptance criteria
SELECT IF(1, 2, '3') = '2'returns1, 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.
- Originating PR: https://github.com/WordPress/sqlite-database-integration/pull/518
- Review discussion: https://github.com/WordPress/sqlite-database-integration/pull/518#discussion_r4194619968
- Related comparison work: https://github.com/WordPress/sqlite-database-integration/pull/508
- Lenguaje dominante
- PHP
- Estrellas
- 363
- Forks
- 72
- Merge medio
- 3 d 7 h
- PR fusionados (30 d)
- 13
Preparar el entorno
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
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de WordPress/sqlite-database-integration
-
MySQL-on-SQLite does not translate DATE arithmetic with INTERVAL HOURPosiblemente ocupada @samuelmbabhazi la tomó hace 28 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
WordPress/sqlite-database-integration#454 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
WordPress/sqlite-database-integration#538 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 40/100
WordPress/sqlite-database-integration#531 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
WordPress/sqlite-database-integration#529 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
WordPress/sqlite-database-integration#528 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de WordPress/sqlite-database-integration
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
nextcloud/integration_openai#446 ·
-
bug customer-reported
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
MagnaCapax/PMSS#1101 ·
Los mantenedores suelen responder en 5 días
-
InvoiceSettled is answered 200 when the invoice cannot be re-fetched, so BTCPay never redelivers itAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
btcpayserver/woocommerce-greenfield-plugin#93 ·
Los mantenedores suelen responder en 1 día
-
kind/bug status/triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100