|
| 1 | +#coding:utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | +ID: issue-8086 |
| 5 | +ISSUE: https://github.com/FirebirdSQL/firebird/issues/8086 |
| 6 | +TITLE: IN predicate with string-type elements is evaluated wrongly against a numeric field |
| 7 | +DESCRIPTION: |
| 8 | +NOTES: |
| 9 | + [06.05.2024] pzotov |
| 10 | + Confirmed bug on 6.0.0.336 |
| 11 | + Checked on 6.0.0.344, 5.0.1.1394 |
| 12 | +""" |
| 13 | + |
| 14 | +import pytest |
| 15 | +from firebird.qa import * |
| 16 | + |
| 17 | +db = db_factory() |
| 18 | + |
| 19 | +test_script = """ |
| 20 | + set bail on; |
| 21 | + set list on; |
| 22 | +
|
| 23 | + recreate table test ( |
| 24 | + id int primary key |
| 25 | + ); |
| 26 | + commit; |
| 27 | +
|
| 28 | + insert into test (id) values (1); |
| 29 | + insert into test (id) values (2); |
| 30 | + insert into test (id) values (3); |
| 31 | + insert into test (id) values (11); |
| 32 | + insert into test (id) values (12); |
| 33 | + insert into test (id) values (13); |
| 34 | +
|
| 35 | + set count on; |
| 36 | +
|
| 37 | + -- this worked fine: |
| 38 | + select 1 as "case-1", t.* from rdb$database r left join test t on t.id in ('1','12') order by t.id; |
| 39 | + select 2 as "case-2", t.* from rdb$database r left join test t on t.id in (2,12) order by t.id; |
| 40 | + select 3 as "case-3", t.* from rdb$database r left join test t on t.id in ('02','12') order by t.id; |
| 41 | +
|
| 42 | + -- this worked wrong before fix: |
| 43 | + select 4 as "case-4", t.* from rdb$database r left join test t on t.id in ('2','12') order by t.id; |
| 44 | +""" |
| 45 | + |
| 46 | +act = isql_act('db', test_script, substitutions=[('[ \t]+', ' ')]) |
| 47 | + |
| 48 | +expected_stdout = """ |
| 49 | + case-1 1 |
| 50 | + ID 1 |
| 51 | + case-1 1 |
| 52 | + ID 12 |
| 53 | + Records affected: 2 |
| 54 | +
|
| 55 | + case-2 2 |
| 56 | + ID 2 |
| 57 | + case-2 2 |
| 58 | + ID 12 |
| 59 | + Records affected: 2 |
| 60 | +
|
| 61 | + case-3 3 |
| 62 | + ID 2 |
| 63 | + case-3 3 |
| 64 | + ID 12 |
| 65 | + Records affected: 2 |
| 66 | +
|
| 67 | + case-4 4 |
| 68 | + ID 2 |
| 69 | + case-4 4 |
| 70 | + ID 12 |
| 71 | + Records affected: 2 |
| 72 | +""" |
| 73 | + |
| 74 | +@pytest.mark.version('>=5.0.1') |
| 75 | +def test_1(act: Action): |
| 76 | + act.expected_stdout = expected_stdout |
| 77 | + act.execute(combine_output = True) |
| 78 | + assert act.clean_stdout == act.clean_expected_stdout |
0 commit comments