6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-23 05:53:06 +01:00
firebird-qa/tests/bugs/core_4240_test.py

93 lines
2.7 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-23 20:41:55 +01:00
"""
ID: issue-4564
ISSUE: 4564
TITLE: Regression: recursive query in SQL query returns incorrect results if more than one branch bypass
DESCRIPTION:
JIRA: CORE-4240
FBTEST: bugs.core_4240
2022-01-23 20:41:55 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
test_script = """
with recursive h
as (select 1 as code_horse,
2 as code_father,
3 as code_mother
from rdb$database
union all
select 2 as code_horse,
4 as code_father,
5 as code_mother
from rdb$database
union all
select 3 as code_horse,
4 as code_father,
5 as code_mother
from rdb$database
union all
select 4 as code_horse,
null as code_father,
null as code_mother
from rdb$database
union all
select 5 as code_horse,
null as code_father,
null as code_mother
from rdb$database),
r
as (select h.code_horse as code_horse,
h.code_father as code_father,
h.code_mother as code_mother,
cast('' as varchar(10)) as mark,
0 as depth
from h
where h.code_horse = 1
union all
select h.code_horse as code_horse,
h.code_father as code_father,
h.code_mother as code_mother,
'f' || r.mark as mark,
r.depth + 1 as depth
from r
join h on r.code_father = h.code_horse
where r.depth < 5
union all
select h.code_horse as code_horse,
h.code_father as code_father,
h.code_mother as code_mother,
'm' || r.mark as mark,
r.depth + 1 as depth
from r
join h on r.code_mother = h.code_horse
where r.depth < 5)
select *
from r
2021-04-26 20:07:00 +02:00
order by 1,2,3,4,5
;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
act = isql_act('db', test_script, substitutions=[('[ \t]+', ' '), ('=', '')])
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
expected_stdout = """
CODE_HORSE CODE_FATHER CODE_MOTHER MARK DEPTH
1 2 3 0
2 4 5 f 1
3 4 5 m 1
4 <null> <null> ff 2
4 <null> <null> fm 2
5 <null> <null> mf 2
5 <null> <null> mm 2
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
2022-01-23 20:41:55 +01:00
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout