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

68 lines
1.6 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
#
# id: bugs.core_1624
# title: MERGE not correctly worked with parameters in MATCHING clause
# decription:
# tracker_id: CORE-1624
# min_versions: ['2.5.0']
# versions: 2.5
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
# version: 2.5
# resources: None
substitutions_1 = [('=.*', '')]
init_script_1 = """"""
db_1 = db_factory(page_size=4096, sql_dialect=3, init=init_script_1)
test_script_1 = """
recreate table src(id int, x int);
recreate table tgt(id int, x int);
commit;
insert into src values(1, 100);
insert into src values(2, 200);
insert into src values(3, 300);
insert into src values(4, 400);
commit;
insert into tgt values(2, 10);
insert into tgt values(3, 20);
commit;
set term ^;
execute block as
declare v_stt varchar(255);
begin
v_stt =
'merge into tgt t using src s on s.id = t.id '
|| 'when matched then update set t.x = s.x + ?'
|| 'when NOT matched then insert values(s.id, s.id + ?)';
execute statement (v_stt) ( 1000, 20000 );
end
^
set term ;^
select * from tgt;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
act_1 = isql_act('db_1', test_script_1, substitutions=substitutions_1)
expected_stdout_1 = """
ID X
============ ============
2 1200
3 1300
1 20001
4 20004
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=2.5')
2021-04-28 12:42:11 +02:00
def test_1(act_1: Action):
2021-04-26 20:07:00 +02:00
act_1.expected_stdout = expected_stdout_1
act_1.execute()
2021-12-22 20:23:11 +01:00
assert act_1.clean_stdout == act_1.clean_expected_stdout
2021-04-26 20:07:00 +02:00