6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 21:43:06 +01:00
firebird-qa/tests/bugs/core_3173_test.py

100 lines
2.2 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-22 21:59:15 +01:00
"""
ID: issue-3547
ISSUE: 3547
TITLE: Empty result when select from SP that contains two CTE (second of them with GROUP BY clause) and INNER join
DESCRIPTION:
JIRA: CORE-3173
FBTEST: bugs.core_3173
2022-01-22 21:59:15 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-22 21:59:15 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-22 21:59:15 +01:00
init_script = """
2021-04-26 20:07:00 +02:00
create or alter procedure sp_main as begin end;
create or alter procedure sp_aux1 as begin end;
commit;
2022-01-22 21:59:15 +01:00
2021-04-26 20:07:00 +02:00
recreate table zzz_tbl (
id integer,
company_id integer,
hire_date date
);
insert into zzz_tbl (id, company_id, hire_date)
values (123456, 654321, '01.10.2004');
commit;
2022-01-22 21:59:15 +01:00
2021-04-26 20:07:00 +02:00
set term ^;
create or alter procedure sp_aux1 returns (val integer)
as begin
val=1;
suspend;
end
^
commit ^
2022-01-22 21:59:15 +01:00
2021-04-26 20:07:00 +02:00
create or alter procedure sp_main (
COMPANY_ID integer,
A_MONTH_BEG date)
returns (
PERSON_ID integer)
AS
begin
for
with
inp as(
select
company_id
,dateadd(1 month to p1)-1 p2
from(
select
:company_id company_id,:a_month_beg p1
--654321 company_id,cast('01.09.2010' as date) p1
from
--rdb$database
sp_aux1
)t
)
2022-01-22 21:59:15 +01:00
2021-04-26 20:07:00 +02:00
,person_nfo as
(
select n.id person_id,i.p2
--from inp i join zzz_tbl n on n.company_id = i.company_id
from zzz_tbl n left join inp i on n.company_id = i.company_id
group by n.id,p2
)
2022-01-22 21:59:15 +01:00
2021-04-26 20:07:00 +02:00
select f.person_id
from person_nfo f
join zzz_tbl nt on nt.hire_date <= f.p2
into :person_id
do suspend;
end
2022-01-22 21:59:15 +01:00
2021-04-26 20:07:00 +02:00
^ set term ;^
commit;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-22 21:59:15 +01:00
db = db_factory(init=init_script)
2021-04-26 20:07:00 +02:00
2022-01-22 21:59:15 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set list on;
select * from sp_main(654321, '01.09.2010');
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-22 21:59:15 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-22 21:59:15 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
PERSON_ID 123456
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-22 21:59:15 +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