1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Provide a two-argument version of the iif() function, plus an alternative

spelling that only requires a single "i".

FossilOrigin-Name: a251ee645e11e24b67473d8a5bd3f8b72fde1ac9d5fda074f5da2297deb2faa8
This commit is contained in:
drh
2024-11-26 20:56:03 +00:00
parent 3e4ccc3208
commit f12e5d1a0f
4 changed files with 27 additions and 13 deletions

View File

@ -1232,12 +1232,18 @@ db nullvalue {}
# EVIDENCE-OF: R-13943-13592 A NULL result is considered untrue when
# evaluating WHEN terms.
#
do_execsql_test e_expr-21.4.1 {
do_execsql_test e_expr-21.4.1a {
SELECT CASE WHEN NULL THEN 'A' WHEN 1 THEN 'B' END, iif(NULL,8,99);
} {B 99}
do_execsql_test e_expr-21.4.2 {
do_execsql_test e_expr-21.4.1b {
SELECT CASE WHEN NULL THEN 'A' WHEN 1 THEN 'B' END, if(NULL,8,99);
} {B 99}
do_execsql_test e_expr-21.4.2a {
SELECT CASE WHEN 0 THEN 'A' WHEN NULL THEN 'B' ELSE 'C' END, iif(0,8,99);
} {C 99}
do_execsql_test e_expr-21.4.2b {
SELECT CASE WHEN 0 THEN 'A' WHEN NULL THEN 'B' ELSE 'C' END, if(0,8,99);
} {C 99}
# EVIDENCE-OF: R-38620-19499 In a CASE with a base expression, the base
# expression is evaluated just once and the result is compared against
@ -1969,9 +1975,12 @@ do_execsql_test e_expr-37.5 {
# EVIDENCE-OF: R-55532-10108 Values 1, 1.0, 0.1, -0.1 and '1english' are
# considered to be true.
#
do_execsql_test e_expr-37.6 {
do_execsql_test e_expr-37.6a {
SELECT CASE WHEN 1 THEN 'true' ELSE 'false' END, iif(1,'true','false');
} {true true}
do_execsql_test e_expr-37.6b {
SELECT CASE WHEN 1 THEN 'true' ELSE 'false' END, if(1,'true');
} {true true}
do_execsql_test e_expr-37.7 {
SELECT CASE WHEN 1.0 THEN 'true' ELSE 'false' END, iif(1.0,'true','false');
} {true true}