6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-23 14:03:06 +01:00
firebird-qa/tests/functional/gtcs/test_computed_fields_13.py

81 lines
2.7 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-02-04 19:05:19 +01:00
"""
ID: computed-fields-13
FBTEST: functional.gtcs.computed_fields_13
TITLE: Computed fields
DESCRIPTION:
Original test see in:
https://github.com/FirebirdSQL/fbtcs/blob/master/GTCS/tests/CF_ISQL_13.script
SQL script for creating test database ('gtcs_sp1.fbk') and fill it with some data:
https://github.com/FirebirdSQL/fbtcs/blob/master/GTCS/tests/PROCS_QA_INIT_ISQL.script
Check that it is not allowed to drop column which is referenced by computed-by column.
"""
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set heading off;
/*---------------------------------------------*/
/* Create a table with computed field. */
/*---------------------------------------------*/
create table t0 (a integer, af computed by (a*3));
insert into t0(a) values(10);
/*---------------------------------------------*/
/* Create a table with nested computed field. */
/*---------------------------------------------*/
create table t1 (a integer, af computed by (a*4), afaf computed by (af*5));
insert into t1(a) values(11);
commit;
/*---------------------------------------------------------------------*/
/* Now alter table and drop the field which is used in computed field. */
/* It shouldn't allow you to drop the field. */
/*---------------------------------------------------------------------*/
alter table t0 drop a;
select 'point-1' msg, p.* from t0 p;
/*---------------------------------------------------------------------*/
/* Now alter table and drop the computed field which is used in other */
2022-02-04 19:05:19 +01:00
/* computed field. */
2021-04-26 20:07:00 +02:00
/* It shouldn't allow you to drop the field. */
/*---------------------------------------------------------------------*/
alter table t1 drop af;
select 'point-2' msg, p.* from t1 p;
"""
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
act = isql_act('db', test_script, substitutions=[('=', ''), ('[ \t]+', ' ')])
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
point-1 10 30
point-2 11 44 220
"""
2022-02-04 19:05:19 +01:00
expected_stderr = """
2021-04-26 20:07:00 +02:00
Statement failed, SQLSTATE 42000
unsuccessful metadata update
-cannot delete
-COLUMN T0.A
-there are 1 dependencies
Statement failed, SQLSTATE 42000
unsuccessful metadata update
-cannot delete
-COLUMN T1.AF
-there are 1 dependencies
"""
2021-04-26 20:07:00 +02:00
2022-02-04 19:05:19 +01:00
@pytest.mark.version('>=3')
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.expected_stderr = expected_stderr
act.execute()
assert (act.clean_stderr == act.clean_expected_stderr and
act.clean_stdout == act.clean_expected_stdout)