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

75 lines
1.9 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-22 21:59:15 +01:00
"""
ID: issue-4097
ISSUE: 4097
TITLE: The trigger together with the operator MERGE if in a condition of connection ON contains new is not compiled
DESCRIPTION:
JIRA: CORE-3753
FBTEST: bugs.core_3753
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
db = db_factory()
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 term ^;
execute block as
begin
begin execute statement 'drop trigger horse_ai'; when any do begin end end
end
^
set term ;^
2022-01-22 21:59:15 +01:00
2021-04-26 20:07:00 +02:00
recreate table cover(id int);
commit;
2022-01-22 21:59:15 +01:00
2021-04-26 20:07:00 +02:00
recreate table horse (
code_horse integer constraint pk_horse primary key,
code_father integer default -2 not null,
code_mother integer default -3 not null,
name varchar(50)
);
2022-01-22 21:59:15 +01:00
2021-04-26 20:07:00 +02:00
recreate table cover (
code_cover integer constraint pk_cover primary key
,code_father integer not null
,code_mother integer not null
,code_horse integer not null
,constraint fk_cover_ref_father foreign key (code_father) references horse (code_horse)
,constraint fk_cover_ref_horse foreign key (code_horse) references horse (code_horse)
,constraint fk_cover_ref_mother foreign key (code_mother) references horse (code_horse)
);
commit;
2022-01-22 21:59:15 +01:00
2021-04-26 20:07:00 +02:00
set term ^;
create or alter trigger horse_ai for horse active after insert position 0 as
begin
merge into cover
using rdb$database as tbl
on cover.code_father = new.code_father and
cover.code_mother = new.code_mother
when matched then
update set
code_horse = new.code_horse
when not matched then
insert (code_horse,
code_father,
code_mother)
values (new.code_horse,
new.code_father,
new.code_mother);
end
^
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
act = isql_act('db', test_script)
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):
2022-01-25 22:55:48 +01:00
act.execute()