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

84 lines
2.1 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-23 20:41:55 +01:00
"""
ID: issue-4357
ISSUE: 4357
TITLE: Creating table with computed fields containing "SELECT FIRST" produces corrupted result
DESCRIPTION: Broken output in ISQL command SHOW TABLE <T> for computed-by field(s).
JIRA: CORE-4027
FBTEST: bugs.core_4027
2022-01-23 20:41:55 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
-- NB: fixed only in 3.0 (checked 30.03.2015)
recreate table test (id int);
commit;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
recreate table contragents (
agent_id int not null
,agent_name varchar(25) not null
);
commit;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
recreate table turnovers(
po_number char(8) not null
,agent_id int not null
,order_date timestamp default 'now' not null
);
commit;
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
recreate table test (
agent_id integer not null,
first_po_number computed by (
(
select first 1 t.po_number
from turnovers t
where t.agent_id=test.agent_id
order by t.order_date
)
),
agent_name computed by (
(
select agent_name
from contragents a
where a.agent_id = test.agent_id
)
)
);
commit;
show table test;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
AGENT_ID INTEGER Not Null
FIRST_PO_NUMBER Computed by: (
(
select first 1 t.po_number
from turnovers t
where t.agent_id=test.agent_id
order by t.order_date
)
)
AGENT_NAME Computed by: (
(
select agent_name
from contragents a
where a.agent_id = test.agent_id
)
)
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0')
2022-01-23 20:41:55 +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