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

72 lines
2.1 KiB
Python

#coding:utf-8
"""
ID: issue-5475
ISSUE: 5475
TITLE: Invalid computed by definition generated by isql -x
DESCRIPTION:
We create table and then run ISQL with '-x' key and saving its output to file.
This operation should NOT produce any error (see var. 'f_xmeta_err').
Then we drop table and run ISQL again but for APPLYING extracted metadata.
If "ISQL -x" will produce script with invalid syntax, compiler will raise error.
JIRA: CORE-5194
FBTEST: bugs.core_5194
"""
import pytest
from firebird.qa import *
init_script = """
recreate table test(a timestamp, b computed by (current_timestamp - a));
"""
db = db_factory(init=init_script)
act = python_act('db', substitutions=[('.* line \\d+ .*', '')])
test_script = """
set list on;
select
rf.rdb$field_name
,ff.rdb$field_length
,ff.rdb$field_scale
,ff.rdb$field_type
,cast(ff.rdb$computed_source as varchar(100)) as rdb$computed_source
from rdb$relation_fields rf
join rdb$fields ff on rf.rdb$field_source = ff.rdb$field_name
where rf.rdb$relation_name='TEST'
order by rdb$field_name;
"""
expected_stdout = """
RDB$FIELD_NAME A
RDB$FIELD_LENGTH 8
RDB$FIELD_SCALE 0
RDB$FIELD_TYPE 35
RDB$COMPUTED_SOURCE <null>
RDB$FIELD_NAME B
RDB$FIELD_LENGTH 8
RDB$FIELD_SCALE -9
RDB$FIELD_TYPE 16
RDB$COMPUTED_SOURCE (current_timestamp - a)
"""
@pytest.mark.version('>=3.0')
def test_1(act: Action):
act.isql(switches=['-x'])
init_meta = act.stdout
#
with act.db.connect() as att1:
cur1 = att1.cursor()
cur1.execute("drop table test")
att1.commit()
#
act.reset()
act.isql(switches=[], input=init_meta)
assert act.clean_stdout == ''
# This should issue DDL of table TEST which was just created by extracted metadata:
act.reset()
act.expected_stdout = expected_stdout
act.isql(switches=['-q'], input= test_script)
assert act.clean_stdout == act.clean_expected_stdout