mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
If a subquery has a result column of the form "CAST(... AS NUMERIC)" then
give that column no affinity rather than NUMERIC affinity. This is because casting to numeric preserves real values that could be integers but numeric affinity does not. By using no affinity on the column, we make the behavior consistent if the subquery is implemented as a co-routine or is materialized. FossilOrigin-Name: ece07d091c2ef3367a914187e0b6512c1f2390b8c34844536ad50e88c7e8c2f2
This commit is contained in:
@ -483,5 +483,36 @@ do_execsql_test cast-9.0 {
|
||||
SELECT v1.c0 FROM v1, t0 WHERE v1.c0=0;
|
||||
} {0}
|
||||
|
||||
# Set the 2022-12-10 "reopen" of ticket [https://sqlite.org/src/tktview/57c47526c3]
|
||||
#
|
||||
do_execsql_test cast-9.1 {
|
||||
CREATE TABLE dual(dummy TEXT);
|
||||
INSERT INTO dual VALUES('X');
|
||||
SELECT CAST(4 AS NUMERIC);
|
||||
} {4}
|
||||
do_execsql_test cast-9.2 {
|
||||
SELECT CAST(4.0 AS NUMERIC);
|
||||
} {4.0}
|
||||
do_execsql_test cast-9.3 {
|
||||
SELECT CAST(4.5 AS NUMERIC);
|
||||
} {4.5}
|
||||
do_execsql_test cast-9.4 {
|
||||
SELECT x, typeof(x) FROM (SELECT CAST(4 AS NUMERIC) AS x) JOIN dual;
|
||||
} {4 integer}
|
||||
do_execsql_test cast-9.5 {
|
||||
SELECT x, typeof(x) FROM (SELECT CAST(4 AS NUMERIC) AS x) CROSS JOIN dual;
|
||||
} {4 integer}
|
||||
do_execsql_test cast-9.10 {
|
||||
SELECT x, typeof(x) FROM (SELECT CAST(4.0 AS NUMERIC) AS x) JOIN dual;
|
||||
} {4.0 real}
|
||||
do_execsql_test cast-9.11 {
|
||||
SELECT x, typeof(x) FROM (SELECT CAST(4.0 AS NUMERIC) AS x) CROSS JOIN dual;
|
||||
} {4.0 real}
|
||||
do_execsql_test cast-9.12 {
|
||||
SELECT x, typeof(x) FROM (SELECT CAST(4.5 AS NUMERIC) AS x) JOIN dual;
|
||||
} {4.5 real}
|
||||
do_execsql_test cast-9.13 {
|
||||
SELECT x, typeof(x) FROM (SELECT CAST(4.5 AS NUMERIC) AS x) CROSS JOIN dual;
|
||||
} {4.5 real}
|
||||
|
||||
finish_test
|
||||
|
Reference in New Issue
Block a user