1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-12-24 14:17:58 +03:00

When doing a text-affinity comparison between two values where one or both

have both a text and a numeric type, make sure the numeric type does not
confuse the answer.  This is a deeper fix to the problem observed by
[forum:/forumpost/3776b48e71|forum pose 3776b48e71].  The problem bisects
to [25f2246be404f38b] on 2014-08-24, prior to version 3.8.7.

FossilOrigin-Name: 709841f88c77276f09701bf38e25503c64b3a0afbe2fbf878136db12f31cbe21
This commit is contained in:
drh
2024-01-20 15:13:13 +00:00
parent 8dca1905ed
commit 4c43f1881e
6 changed files with 115 additions and 14 deletions

View File

@@ -12,8 +12,6 @@
# of this file is testing the interaction of SQLite manifest types
# with Tcl dual-representations.
#
# $Id: types3.test,v 1.8 2008/04/28 13:02:58 drh Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -96,4 +94,32 @@ do_test types3-2.6 {
tcl_variable_type V
} {}
# See https://sqlite.org/forum/forumpost/3776b48e71
#
# On a text-affinity comparison of two values where one of
# the values has both MEM_Str and a numeric type like MEM_Int,
# make sure that only the MEM_Str representation is used.
#
sqlite3_create_function db
do_execsql_test types3-3.1 {
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(x TEXT PRIMARY KEY);
INSERT INTO t1 VALUES('1');
SELECT * FROM t1 WHERE NOT x=upper(1);
} {}
do_execsql_test types3-3.2 {
SELECT * FROM t1 WHERE NOT x=add_text_type(1);
} {}
do_execsql_test types3-3.3 {
SELECT * FROM t1 WHERE NOT x=add_int_type('1');
} {}
do_execsql_test types3-3.4 {
DELETE FROM t1;
INSERT INTO t1 VALUES(1.25);
SELECT * FROM t1 WHERE NOT x=add_real_type('1.25');
} {}
do_execsql_test types3-3.5 {
SELECT * FROM t1 WHERE NOT x=add_text_type(1.25);
} {}
finish_test