1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-27 20:41:58 +03:00

NULL values are distinct. A comparison involving a NULL is always false.

Operations on a NULL value yield a NULL result.  This change makes SQLite
operate more like the SQL spec, but it may break existing applications that
assumed the old behavior.  All the old tests pass but we still need to add
new tests to better verify the new behavior.  Fix for ticket #44. (CVS 589)

FossilOrigin-Name: 9051173742f1b0e15a809d12a0c9c98fd2c4614d
This commit is contained in:
drh
2002-05-26 20:54:33 +00:00
parent 195e6967fb
commit f5905aa7be
15 changed files with 485 additions and 238 deletions

View File

@ -12,7 +12,7 @@
# focus of this file is testing UNION, INTERSECT and EXCEPT operators
# in SELECT statements.
#
# $Id: select4.test,v 1.6 2002/05/24 16:14:16 drh Exp $
# $Id: select4.test,v 1.7 2002/05/26 20:54:35 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -249,6 +249,48 @@ do_test select4-6.2 {
}
} {0 1 1 1 2 2 3 4 3 7 4 8 5 15}
# NULLs are distinct. Make sure the UNION operator recognizes this
#
do_test select4-6.3 {
execsql {
SELECT NULL UNION SELECT NULL UNION
SELECT 1 UNION SELECT 2 AS 'x'
ORDER BY x;
}
} {{} {} 1 2}
do_test select4-6.3 {
execsql {
SELECT NULL UNION ALL SELECT NULL UNION ALL
SELECT 1 UNION ALL SELECT 2 AS 'x'
ORDER BY x;
}
} {{} {} 1 2}
# Make sure the DISTINCT keyword treats NULLs as DISTINCT
#
do_test select4-6.4 {
execsql {
SELECT * FROM (
SELECT NULL, 1 UNION ALL SELECT NULL, 1
);
}
} {{} 1 {} 1}
do_test select4-6.5 {
execsql {
SELECT DISTINCT * FROM (
SELECT NULL, 1 UNION ALL SELECT NULL, 1
);
}
} {{} 1 {} 1}
do_test select4-6.6 {
execsql {
SELECT DISTINCT * FROM (
SELECT 1,2 UNION ALL SELECT 1,2
);
}
} {1 2}
# Make sure column names are correct when a compound select appears as
# an expression in the WHERE clause.
#