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

77 lines
2.2 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-20 17:32:14 +01:00
"""
ID: issue-1872
ISSUE: 1872
TITLE: ALTER mechanism for computed fields
DESCRIPTION:
Computed field had a lot of inconsistencies and problems
It's possible to use a explicit type, but only together with a (new) computed expression.
JIRA: CORE-1454
FBTEST: bugs.core_1454
2022-01-20 17:32:14 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
init_script = """
2021-04-26 20:07:00 +02:00
recreate table t (
f1 varchar(10),
f2 varchar(10),
cf computed by (f1 || ' - ' || f2)
);
2022-01-12 10:17:32 +01:00
2021-04-26 20:07:00 +02:00
insert into t (f1,f2) values ('0123456789','abcdefghij');
commit;
"""
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
db = db_factory(init=init_script, charset='win1252')
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set list on;
set width fld_name 31;
set width fld_expr 80;
select f1,f2,cf from t;
2022-01-12 10:17:32 +01:00
2021-04-26 20:07:00 +02:00
select b.rdb$field_name fld_name, cast(a.rdb$computed_source as varchar(80)) fld_expr, a.rdb$field_length fld_length
from rdb$fields a
join rdb$relation_fields b
on a.rdb$field_name = b.rdb$field_source
where b.rdb$field_name = upper('cf');
2022-01-12 10:17:32 +01:00
2021-04-26 20:07:00 +02:00
alter table t alter cf type varchar(30) computed by (f1 || ' - ' || f2 || ' - more');
commit;
2022-01-12 10:17:32 +01:00
2021-04-26 20:07:00 +02:00
select f1,f2,cf from t;
2022-01-12 10:17:32 +01:00
2021-04-26 20:07:00 +02:00
select b.rdb$field_name fld_name, cast(a.rdb$computed_source as varchar(80)) fld_expr, a.rdb$field_length fld_length
from rdb$fields a
join rdb$relation_fields b
on a.rdb$field_name = b.rdb$field_source
where b.rdb$field_name = upper('cf');
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
expected_stdout = """
F1 0123456789
F2 abcdefghij
CF 0123456789 - abcdefghij
2022-01-12 10:17:32 +01:00
FLD_NAME CF
FLD_EXPR (f1 || ' - ' || f2)
FLD_LENGTH 23
F1 0123456789
F2 abcdefghij
CF 0123456789 - abcdefghij - more
2022-01-12 10:17:32 +01:00
FLD_NAME CF
FLD_EXPR (f1 || ' - ' || f2 || ' - more')
FLD_LENGTH 30
2021-08-03 23:29:08 +02:00
"""
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
@pytest.mark.version('>=3')
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout