mirror of
https://github.com/FirebirdSQL/firebird-qa.git
synced 2025-01-22 13:33:07 +01:00
Added/Updated tests\bugs\core_3692_test.py: fixed wrong section in the head of test
This commit is contained in:
parent
ae7bf5006e
commit
23be1eafef
@ -7,89 +7,40 @@ TITLE: Cannot drop a NOT NULL constraint on a field participating in the U
|
||||
DESCRIPTION:
|
||||
JIRA: CORE-3692
|
||||
FBTEST: bugs.core_3692
|
||||
NOTES:
|
||||
[05.10.2023] pzotov
|
||||
Removed SHOW command for check result because its output often changes.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from firebird.qa import *
|
||||
|
||||
init_script = """
|
||||
recreate table cset (cname varchar(250) character set none not null);
|
||||
recreate table test (s varchar(250) character set none not null);
|
||||
commit;
|
||||
alter table cset add constraint uq_cset unique (cname);
|
||||
alter table test add constraint test_unq unique (s);
|
||||
commit;
|
||||
"""
|
||||
|
||||
db = db_factory(init=init_script)
|
||||
|
||||
test_script = """
|
||||
show table cset;
|
||||
|
||||
set term ^;
|
||||
execute block as
|
||||
declare v_stt varchar(70);
|
||||
begin
|
||||
for
|
||||
with
|
||||
inp as(select 'cset' nm from rdb$database)
|
||||
,pk_defs as( -- obtain PK constraint and get fields that assembles it
|
||||
select
|
||||
rc.rdb$relation_name rel_name
|
||||
,rc.rdb$constraint_name pk_name
|
||||
,rc.rdb$index_name pk_idx
|
||||
,rs.rdb$field_name fld_name
|
||||
,rs.rdb$field_position fld_pos
|
||||
from rdb$relation_constraints rc
|
||||
join rdb$index_segments rs on rc.rdb$index_name=rs.rdb$index_name
|
||||
join inp i on rc.rdb$relation_name containing i.nm
|
||||
where rc.rdb$constraint_type containing 'PRIMARY'
|
||||
)
|
||||
-- select * from pk_defs
|
||||
,chk_list as(
|
||||
select
|
||||
rc.rdb$relation_name rel_name
|
||||
,rc.rdb$constraint_name sub_name
|
||||
,rc.rdb$constraint_type sub_type
|
||||
,'alter table '||trim(rc.rdb$relation_name)||' drop constraint '||trim(rc.rdb$constraint_name)||'; -- '||trim(rc.rdb$constraint_type) stt
|
||||
,ck.rdb$trigger_name
|
||||
,p.pk_name -- not null ==> field is included in PK, skip it
|
||||
,decode(rc.rdb$constraint_type, 'UNIQUE', 99, 0) sort_weitgh
|
||||
from rdb$relation_constraints rc
|
||||
join inp i on rc.rdb$relation_name containing i.nm
|
||||
left join rdb$check_constraints ck on rc.rdb$constraint_name=ck.rdb$constraint_name
|
||||
left join pk_defs p on rc.rdb$relation_name=p.rel_name and ck.rdb$trigger_name=p.fld_name
|
||||
where
|
||||
rc.rdb$relation_name not like 'RDB$%'
|
||||
and rc.rdb$relation_name not like 'MON$%'
|
||||
and rc.rdb$relation_name not like 'IBE$%'
|
||||
and rc.rdb$constraint_type not containing 'PRIMARY'
|
||||
and p.pk_name is null -- ==> this field is NOT included in PK constraint
|
||||
order by rc.rdb$relation_name, decode(rc.rdb$constraint_type, 'UNIQUE', 99, 0)
|
||||
)
|
||||
select cast(stt as varchar(70)) stt from chk_list
|
||||
into v_stt
|
||||
do begin
|
||||
execute statement (v_stt);
|
||||
end
|
||||
|
||||
end
|
||||
^ set term ;^
|
||||
set bail on;
|
||||
set list on;
|
||||
alter table test alter column s drop not null;
|
||||
commit;
|
||||
|
||||
show table cset;
|
||||
insert into test(s) values(null);
|
||||
select s from test;
|
||||
"""
|
||||
|
||||
act = isql_act('db', test_script)
|
||||
act = isql_act('db', test_script, substitutions = [ ('[ \t]+', ''), ] )
|
||||
|
||||
expected_stdout = """
|
||||
CNAME VARCHAR(250) Not Null
|
||||
CONSTRAINT UQ_CSET:
|
||||
Unique key (CNAME)
|
||||
CNAME VARCHAR(250) Nullable
|
||||
S <null>
|
||||
"""
|
||||
|
||||
@pytest.mark.version('>=3')
|
||||
def test_1(act: Action):
|
||||
act.expected_stdout = expected_stdout
|
||||
act.execute()
|
||||
act.execute(combine_output = True)
|
||||
assert act.clean_stdout == act.clean_expected_stdout
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user