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

51 lines
2.0 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-27 20:08:36 +01:00
"""
ID: issue-6365
ISSUE: 6365
TITLE: The Metadata script extracted using ISQL of a database restored from a Firebird
2.5.9 Backup is invalid/incorrect when table has COMPUTED BY field
2022-01-27 20:08:36 +01:00
DESCRIPTION:
Test uses backup of preliminary created database in FB 2.5.9, DDL is the same as in the ticket.
This .fbk is restored and we launch ISQL -X in order to get metadata. Then we check that two
in this script with "COMPUTED BY" phrase contain non zero number as width of this field:
1) line that belongs to CREATE TABLE statement:
FULL_NAME VARCHAR(100) ... COMPUTED BY ...
2) line with ALTER COLUMN statement:
ALTER FULL_NAME TYPE VARCHAR(100) ... COMPUTED BY ...
JIRA: CORE-6116
FBTEST: bugs.core_6116
2022-01-27 20:08:36 +01:00
"""
2021-04-26 20:07:00 +02:00
import pytest
2021-12-10 19:50:31 +01:00
import re
2022-01-27 20:08:36 +01:00
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
db = db_factory(from_backup='core6116-25.fbk')
2021-12-10 19:50:31 +01:00
2022-01-27 20:08:36 +01:00
act = python_act('db')
2021-04-26 20:07:00 +02:00
2022-01-27 20:08:36 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
Length in "CREATE TABLE" statement: 100
Length in "ALTER COLUMN" statement: 100
2021-12-10 19:50:31 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=3.0.6')
2022-01-27 20:08:36 +01:00
def test_1(act: Action, capsys):
2021-12-10 19:50:31 +01:00
comp_field_initial_ptn = re.compile( 'FULL_NAME\\s+VARCHAR\\(\\d+\\).*COMPUTED BY', re.IGNORECASE )
comp_field_altered_ptn = re.compile( 'ALTER\\s+FULL_NAME\\s+TYPE\\s+VARCHAR\\(\\d+\\).*COMPUTED BY', re.IGNORECASE )
#
2022-01-27 20:08:36 +01:00
act.isql(switches=['-x'])
for line in act.stdout.splitlines():
2021-12-10 19:50:31 +01:00
if comp_field_initial_ptn.search(line):
words = line.replace('(',' ').replace(')',' ').split() # ['FULL_NAME', 'VARCHAR', '0', ... , 'COMPUTED', 'BY']
print(f'Length in "CREATE TABLE" statement: {words[2]}')
if comp_field_altered_ptn.search(line):
words = line.replace('(',' ').replace(')',' ').split() # ['ALTER', 'FULL_NAME', 'TYPE', 'VARCHAR', '0', ... , 'COMPUTED', 'BY']
print(f'Length in "ALTER COLUMN" statement: {words[4]}')
# Check
2022-01-27 20:08:36 +01:00
act.reset()
act.expected_stdout = expected_stdout
act.stdout = capsys.readouterr().out
assert act.clean_stdout == act.clean_expected_stdout