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_5351_test.py

73 lines
1.6 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-25 22:55:48 +01:00
"""
ID: issue-5624
ISSUE: 5624
TITLE: LEFT JOIN incorrectly pushes UDF into the inner stream causing wrong results
DESCRIPTION:
NOTES:
[25.01.2019]
totally changed: use ticket author's sample + dimitr's suggestion
to operate with usual PSQL fcuntion (rather than UDF).
Thus test nothing has to do with UDF or UDR.
JIRA: CORE-5351
FBTEST: bugs.core_5351
2022-01-25 22:55:48 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set bail on;
set term ^;
2022-01-25 22:55:48 +01:00
create or alter function psql_strlen (val varchar(10)) returns int as
begin
return char_length(coalesce(val, ''));
2021-04-26 20:07:00 +02:00
end
^
set term ;^
commit;
2022-01-25 22:55:48 +01:00
recreate table test_table1 (
id integer not null,
testtable2_id integer
);
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
alter table test_table1 add primary key (id);
commit;
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
recreate table test_table2 (
id integer not null,
groupcode varchar(10)
);
alter table test_table2 add primary key (id);
commit;
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
insert into test_table1 (id,testtable2_id) values (1,100);
insert into test_table2 (id,groupcode) values (100,'a');
commit;
2021-04-26 20:07:00 +02:00
set count on;
set list on;
2022-01-25 22:55:48 +01:00
select t1.id
from test_table1 t1
2021-04-26 20:07:00 +02:00
left join test_table2 t2 on t2.id=t1.testtable2_id
where psql_strlen(t2.groupcode) = 0 ;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
Records affected: 0
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0.1')
2022-01-25 22:55:48 +01:00
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout