6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 13:33:07 +01:00
firebird-qa/tests/bugs/core_0149_test.py

231 lines
6.5 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-18 20:45:21 +01:00
"""
ID: issue-478
ISSUE: 478
TITLE: Left joining views with null fails
DESCRIPTION:
JIRA: CORE-149
FBTEST: bugs.core_0149
2022-01-18 20:45:21 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set list on;
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
-- Initial comment by johnsparrowuk, 19/Mar/04 12:00 AM:
recreate view currentpeople(k) as select 1 as k from rdb$database;
2021-12-22 20:23:11 +01:00
recreate view finishedpeople(k) as select 1 as k from rdb$database;
2021-04-26 20:07:00 +02:00
commit;
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
recreate table mytable (
person varchar(20) not null,
status int not null, primary key (person,status)
);
2021-12-22 20:23:11 +01:00
recreate view currentpeople(person) as
2021-04-26 20:07:00 +02:00
select distinct person as person
from mytable where status = 1;
2021-12-22 20:23:11 +01:00
recreate view finishedpeople(person) as
2021-04-26 20:07:00 +02:00
select distinct person as person
from mytable where status = 2;
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
insert into mytable values ('john',1);
insert into mytable values ('john',2);
insert into mytable values ('fred',1);
commit;
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
-- This works fine: fred-null, john-john
2021-12-22 20:23:11 +01:00
select *
from currentpeople c
2021-04-26 20:07:00 +02:00
left join finishedpeople f on c.person = f.person
order by c.person, f.person
;
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
-- This is as expected too: john-john
select *
2021-12-22 20:23:11 +01:00
from currentpeople c
2021-04-26 20:07:00 +02:00
left join finishedpeople f
on c.person = f.person where f.person = 'john'
order by c.person, f.person
;
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
-- WHATS HAPPENING HERE????? fred-null, JOHN-NULL where does the john-null come from???
2021-12-22 20:23:11 +01:00
select *
from currentpeople c
2021-04-26 20:07:00 +02:00
left join finishedpeople f on c.person = f.person
where f.person is null
order by c.person, f.person
;
commit;
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
--#################################################
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
-- Alice F. Bird added a comment - 14/Jun/06 09:32 AM
recreate table test (
id int not null,
name varchar(15),
pid integer
);
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
insert into test(id, name, pid) values(1, 'Car', null);
insert into test(id, name, pid) values(2, 'Engine', 1);
insert into test(id, name, pid) values(3, 'Body', 1);
insert into test(id, name, pid) values(4, 'Oil Filter',2);
insert into test(id, name, pid) values(5, 'Air Filter',2);
insert into test(id, name, pid) values(6, 'Door Left', 3);
insert into test(id, name, pid) values(7, 'Door Right',3);
commit;
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
-- This query issued WRONG result on 1.5.6
-- (because first data source - 'TEST' - has not alias)
select *
from test
left outer join test t2
on test.pid=t2.id
order by test.id, t2.id
;
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
-- This works fine:
select *
from test t1
left outer join test t2
on t1.pid=t2.id
order by t1.id, t2.id
;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
PERSON fred
PERSON <null>
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
PERSON john
PERSON john
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
PERSON john
PERSON john
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
PERSON fred
PERSON <null>
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
ID 1
NAME Car
PID <null>
ID <null>
NAME <null>
PID <null>
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
ID 2
NAME Engine
PID 1
ID 1
NAME Car
PID <null>
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
ID 3
NAME Body
PID 1
ID 1
NAME Car
PID <null>
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
ID 4
NAME Oil Filter
PID 2
ID 2
NAME Engine
PID 1
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
ID 5
NAME Air Filter
PID 2
ID 2
NAME Engine
PID 1
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
ID 6
NAME Door Left
PID 3
ID 3
NAME Body
PID 1
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
ID 7
NAME Door Right
PID 3
ID 3
NAME Body
PID 1
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
ID 1
NAME Car
PID <null>
ID <null>
NAME <null>
PID <null>
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
ID 2
NAME Engine
PID 1
ID 1
NAME Car
PID <null>
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
ID 3
NAME Body
PID 1
ID 1
NAME Car
PID <null>
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
ID 4
NAME Oil Filter
PID 2
ID 2
NAME Engine
PID 1
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
ID 5
NAME Air Filter
PID 2
ID 2
NAME Engine
PID 1
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
ID 6
NAME Door Left
PID 3
ID 3
NAME Body
PID 1
2021-12-22 20:23:11 +01:00
2021-04-26 20:07:00 +02:00
ID 7
NAME Door Right
PID 3
ID 3
NAME Body
PID 1
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +01:00
@pytest.mark.version('>=3')
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout
2021-04-26 20:07:00 +02:00