6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 21:43:06 +01:00
firebird-qa/tests/bugs/core_1036_test.py

77 lines
2.4 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-19 17:54:56 +01:00
"""
ID: issue-1453
ISSUE: 1453
TITLE: Extend returning support added in ver 2 in update record of table and in updateble view
DESCRIPTION:
Only basic support is checked here (i.e. only table and one-to-one projection view,
WITHOUT trigger(s)).
JIRA: CORE-1036
"""
2021-04-26 20:07:00 +02:00
2022-01-19 17:54:56 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-19 17:54:56 +01:00
init_script = """
2021-04-26 20:07:00 +02:00
recreate view v_test as select 1 x from rdb$database;
commit;
recreate table test(id int primary key, x int default 11, y int default 12, z computed by(x+y) );
commit;
recreate view v_test as select id, x, y, z from test;
commit;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-19 17:54:56 +01:00
db = db_factory(init=init_script)
2021-04-26 20:07:00 +02:00
2022-01-19 17:54:56 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set list on;
insert into test(id, x, y) values(1,100,200);
commit;
insert into test(id) values(2) returning x as t_inserted_x, y as t_inserted_y, z as t_inserted_z;
update test set id=-id, x=-2*y, y=-3*x where id=1 returning x as t_updated_x, y as t_updated_y, z as t_updated_z;
delete from test where id < 0 returning x as t_deleted_x, y as t_deleted_y, z as t_deleted_z;
delete from test;
insert into test(id, x, y) values(1,100,200);
commit;
insert into v_test(id) values(3) returning x as v_inserted_x, y as v_inserted_y, z as v_inserted_z;
update v_test set id=-id, x=-2*y, y=-3*x where id=1 returning x as v_updated_x, y as v_updated_y, z as v_updated_z;
delete from v_test where id < 0 returning x as v_deleted_x, y as v_deleted_y, z as v_deleted_z;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-19 17:54:56 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-19 17:54:56 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
T_INSERTED_X 11
T_INSERTED_Y 12
T_INSERTED_Z 23
T_UPDATED_X -400
T_UPDATED_Y -300
T_UPDATED_Z -700
T_DELETED_X -400
T_DELETED_Y -300
T_DELETED_Z -700
V_INSERTED_X 11
V_INSERTED_Y 12
V_INSERTED_Z 23
V_UPDATED_X -400
V_UPDATED_Y -300
V_UPDATED_Z -700
V_DELETED_X -400
V_DELETED_Y -300
V_DELETED_Z -700
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
2022-01-19 17:54:56 +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