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

67 lines
1.7 KiB
Python

#coding:utf-8
"""
ID: computed-fields-10
FBTEST: functional.gtcs.computed_fields_10
TITLE: Computed fields
DESCRIPTION:
Original test see in:
https://github.com/FirebirdSQL/fbtcs/blob/master/GTCS/tests/CF_ISQL_10.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
"""
import pytest
from firebird.qa import *
db = db_factory()
test_script = """
set bail on;
set heading off;
-- Test verifies COMPUTED-BY field which expression involves GEN_ID() call.
create generator gen1;
set generator gen1 to 1000;
commit; -- show generator gen1;
/*----------------------------*/
/* Computed by (a + gen_id()) */
/*----------------------------*/
create table t0 (a integer, genid_field computed by (a + gen_id(gen1, 1)));
commit; -- t0;
insert into t0(a) values(10);
insert into t0(a) values(12);
select * from t0;
set generator gen1 to 1000;
select * from t0;
/*
** Since computed fields are evaluated during run-time, the computed
** field with gen_id() will be different every-time. So, the following
** select will never have a match.
*/
set generator gen1 to 1000;
select * from t0 where genid_field = gen_id(gen1, 1);
"""
act = isql_act('db', test_script, substitutions=[('=', ''), ('[ \t]+', ' ')])
expected_stdout = """
10 1011
12 1014
10 1011
12 1014
"""
@pytest.mark.version('>=3')
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout