2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
"""
|
|
|
|
ID: issue-4220
|
|
|
|
ISSUE: 4220
|
|
|
|
TITLE: Ambiguous field name in the trigger when it does a select from the table
|
|
|
|
DESCRIPTION:
|
|
|
|
JIRA: CORE-3883
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_3883
|
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
|
|
|
recreate table regtype (
|
|
|
|
code_regtype int constraint pk_regtype primary key,
|
|
|
|
name varchar(20),
|
|
|
|
multirecord smallint
|
|
|
|
);
|
2022-01-22 21:59:15 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
recreate table reg (
|
|
|
|
code_reg int constraint pk_reg primary key,
|
|
|
|
code_regtype int,
|
|
|
|
code_horse int
|
|
|
|
);
|
|
|
|
|
|
|
|
create exception e_duplicate_reg 'duplicate registration info';
|
2022-01-22 21:59:15 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
set term ^ ;
|
|
|
|
create or alter trigger reg_bi0 for reg
|
|
|
|
active before insert position 0 as
|
|
|
|
begin
|
|
|
|
if (exists(select 1
|
|
|
|
from reg
|
|
|
|
inner join regtype on reg.code_regtype = regtype.code_regtype
|
|
|
|
where reg.code_horse = new.code_horse and
|
|
|
|
reg.code_regtype = new.code_regtype and
|
|
|
|
regtype.multirecord = 0)) then
|
|
|
|
exception e_duplicate_reg;
|
|
|
|
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()
|