2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-24 20:27:02 +01:00
|
|
|
"""
|
|
|
|
ID: issue-5225
|
|
|
|
ISSUE: 5225
|
|
|
|
TITLE: Different collation ID for altered computed column
|
|
|
|
DESCRIPTION:
|
|
|
|
JIRA: CORE-4934
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_4934
|
2022-01-24 20:27:02 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-24 20:27:02 +01:00
|
|
|
import pytest
|
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-24 20:27:02 +01:00
|
|
|
db = db_factory()
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-24 20:27:02 +01:00
|
|
|
test_script = """
|
2021-04-26 20:07:00 +02:00
|
|
|
recreate table t_country(id int);
|
|
|
|
commit;
|
2022-01-24 20:27:02 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
create or alter view v_test as
|
|
|
|
select
|
|
|
|
rf.rdb$relation_name rel_name
|
|
|
|
,rf.rdb$field_name fld_name
|
|
|
|
--,rf.rdb$field_source fld_source
|
|
|
|
,f.rdb$character_set_id cset_id
|
|
|
|
,f.rdb$collation_id coll_id
|
|
|
|
from rdb$relation_fields rf
|
|
|
|
left join rdb$fields f on rf.rdb$field_source = f.rdb$field_name
|
|
|
|
where rf.rdb$relation_name in( upper('t_country'), upper('t_translation_meta'))
|
|
|
|
order by 1,2;
|
2022-01-24 20:27:02 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
commit;
|
2022-01-24 20:27:02 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
recreate table t_translation_meta (
|
|
|
|
f_trm_id bigint not null,
|
|
|
|
f_trm_code varchar(512) character set utf8 not null collate
|
|
|
|
unicode_ci
|
|
|
|
);
|
|
|
|
commit;
|
2022-01-24 20:27:02 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
recreate table t_country (
|
|
|
|
f_cnr_id bigint not null,
|
|
|
|
f_trm_name_id bigint default -1 not null,
|
|
|
|
cf_cnr_name computed by (
|
|
|
|
(
|
|
|
|
(
|
|
|
|
select f_trm_code
|
|
|
|
from t_translation_meta
|
|
|
|
where f_trm_id = f_trm_name_id
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
commit;
|
2022-01-24 20:27:02 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
set width rel_name 20;
|
|
|
|
set width fld_name 20;
|
|
|
|
set width fld_source 20;
|
2022-01-24 20:27:02 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
set list on;
|
2022-01-24 20:27:02 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
select 'before' msg, v.* from v_test v;
|
2022-01-24 20:27:02 +01:00
|
|
|
|
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
alter table t_country alter cf_cnr_name computed by
|
|
|
|
(
|
|
|
|
(
|
|
|
|
(
|
|
|
|
select
|
|
|
|
f_trm_code
|
|
|
|
from t_translation_meta
|
|
|
|
where f_trm_id = f_trm_name_id
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
commit;
|
2022-01-24 20:27:02 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
select 'after' msg, v.* from v_test v;
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-24 20:27:02 +01:00
|
|
|
act = isql_act('db', test_script)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-24 20:27:02 +01:00
|
|
|
expected_stdout = """
|
2021-04-26 20:07:00 +02:00
|
|
|
MSG before
|
2022-01-24 20:27:02 +01:00
|
|
|
REL_NAME T_COUNTRY
|
|
|
|
FLD_NAME CF_CNR_NAME
|
2021-04-26 20:07:00 +02:00
|
|
|
CSET_ID 4
|
|
|
|
COLL_ID 3
|
2022-01-24 20:27:02 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
MSG before
|
2022-01-24 20:27:02 +01:00
|
|
|
REL_NAME T_COUNTRY
|
|
|
|
FLD_NAME F_CNR_ID
|
2021-04-26 20:07:00 +02:00
|
|
|
CSET_ID <null>
|
|
|
|
COLL_ID <null>
|
2022-01-24 20:27:02 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
MSG before
|
2022-01-24 20:27:02 +01:00
|
|
|
REL_NAME T_COUNTRY
|
|
|
|
FLD_NAME F_TRM_NAME_ID
|
2021-04-26 20:07:00 +02:00
|
|
|
CSET_ID <null>
|
|
|
|
COLL_ID <null>
|
2022-01-24 20:27:02 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
MSG before
|
2022-01-24 20:27:02 +01:00
|
|
|
REL_NAME T_TRANSLATION_META
|
|
|
|
FLD_NAME F_TRM_CODE
|
2021-04-26 20:07:00 +02:00
|
|
|
CSET_ID 4
|
|
|
|
COLL_ID 3
|
2022-01-24 20:27:02 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
MSG before
|
2022-01-24 20:27:02 +01:00
|
|
|
REL_NAME T_TRANSLATION_META
|
|
|
|
FLD_NAME F_TRM_ID
|
2021-04-26 20:07:00 +02:00
|
|
|
CSET_ID <null>
|
|
|
|
COLL_ID <null>
|
2022-01-24 20:27:02 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
MSG after
|
2022-01-24 20:27:02 +01:00
|
|
|
REL_NAME T_COUNTRY
|
|
|
|
FLD_NAME CF_CNR_NAME
|
2021-04-26 20:07:00 +02:00
|
|
|
CSET_ID 4
|
|
|
|
COLL_ID 3
|
2022-01-24 20:27:02 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
MSG after
|
2022-01-24 20:27:02 +01:00
|
|
|
REL_NAME T_COUNTRY
|
|
|
|
FLD_NAME F_CNR_ID
|
2021-04-26 20:07:00 +02:00
|
|
|
CSET_ID <null>
|
|
|
|
COLL_ID <null>
|
2022-01-24 20:27:02 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
MSG after
|
2022-01-24 20:27:02 +01:00
|
|
|
REL_NAME T_COUNTRY
|
|
|
|
FLD_NAME F_TRM_NAME_ID
|
2021-04-26 20:07:00 +02:00
|
|
|
CSET_ID <null>
|
|
|
|
COLL_ID <null>
|
2022-01-24 20:27:02 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
MSG after
|
2022-01-24 20:27:02 +01:00
|
|
|
REL_NAME T_TRANSLATION_META
|
|
|
|
FLD_NAME F_TRM_CODE
|
2021-04-26 20:07:00 +02:00
|
|
|
CSET_ID 4
|
|
|
|
COLL_ID 3
|
2022-01-24 20:27:02 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
MSG after
|
2022-01-24 20:27:02 +01:00
|
|
|
REL_NAME T_TRANSLATION_META
|
|
|
|
FLD_NAME F_TRM_ID
|
2021-04-26 20:07:00 +02:00
|
|
|
CSET_ID <null>
|
|
|
|
COLL_ID <null>
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
@pytest.mark.version('>=3.0')
|
2022-01-24 20:27:02 +01:00
|
|
|
def test_1(act: Action):
|
|
|
|
act.expected_stdout = expected_stdout
|
|
|
|
act.execute()
|
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|
2021-04-26 20:07:00 +02:00
|
|
|
|