Skip to content

Commit 1d6cfa0

Browse files
committed
Added/Updated tests\bugs\core_5167_test.py: replace one of expression which must fail after commit 3fabcb5b: IN-predicate is evaluated differently in FB 5.x. See notes.
1 parent 3a97423 commit 1d6cfa0

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

tests/bugs/core_5167_test.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,25 @@
55
ISSUE: 5450
66
TITLE: Allow implicit conversion between boolean and string
77
DESCRIPTION:
8-
Test contains of TWO set of expressions: those which should finish OK and which should FAIL.
9-
Expressions that should work fine are called directly with checking only their result.
10-
Expressions that should fail are inserted into table and are called via ES from cursor on that table.
11-
Inside this cursor we register values of gdscode and sqlstate that raise, and issue via output args
12-
three columns: statement, gdscode, sqlstate. This output is then checked for matching with expected.
8+
Test contains TWO set of expressions: those which should finish OK and which should FAIL.
9+
Expressions that should work fine are called directly with checking only their result.
10+
Expressions that should fail are inserted into table and are called via ES from cursor on that table.
11+
Inside this cursor we register values of gdscode and sqlstate that raise, and issue via output args
12+
three columns: statement, gdscode, sqlstate. This output is then checked for matching with expected.
1313
JIRA: CORE-5167
1414
FBTEST: bugs.core_5167
15+
NOTES:
16+
[06.09.2023] pzotov
17+
Expression "true in ('unknown', 'false', 'true')" failed in FB 3.x/4.x because first literal ('unknown')
18+
could not be conversed properly. This was expected: old algorithm of IN(<list>) compared literals using "OR" basis,
19+
from left to right, one by one.
20+
But this is not so in FB 5.x+ since changed algorithm of IN(<list>), and this expression is evaluated
21+
successfully. Because of that, it was decided to replace this expr. with:
22+
"select 'unknown' in (true) as result from rdb$database" (it fails on any major FB version).
23+
See also:
24+
1) https://github.com/FirebirdSQL/firebird/commit/0493422c9f729e27be0112ab60f77e753fabcb5b
25+
("Better processing and optimization if IN <list> predicates (#7707)")
26+
2) letter from dimitr, 05-sep-2023 20:51
1527
"""
1628

1729
import pytest
@@ -112,7 +124,7 @@
112124
113125
-- convers error:
114126
insert into test(id, expr) values(gen_id(g,1), 'select true = ''unknown'' as result from rdb$database'); -- convers error
115-
insert into test(id, expr) values(gen_id(g,1), 'select true in (''unknown'', ''false'', ''true'') as result from rdb$database'); -- convers error
127+
insert into test(id, expr) values(gen_id(g,1), 'select ''unknown'' in (true) as result from rdb$database'); -- convers error
116128
insert into test(id, expr) values(gen_id(g,1), 'select cast(''true'' as blob) > false as result from rdb$database');
117129
insert into test(id, expr) values(gen_id(g,1), 'select list(b, '''') > false as result from (select ''true'' as b from rdb$database)');
118130
commit;
@@ -341,7 +353,7 @@
341353
RAISED_SQL 22018
342354
343355
EXPR_NO 38
344-
RUN_EXPR select true in ('unknown', 'false', 'true') as result from rdb$database
356+
RUN_EXPR select 'unknown' in (true) as result from rdb$database
345357
RAISED_GDS 335544334
346358
RAISED_SQL 22018
347359

0 commit comments

Comments
 (0)