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

95 lines
3.2 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-25 22:55:48 +01:00
"""
ID: issue-5377
ISSUE: https://github.com/FirebirdSQL/firebird/issues/5377
2022-01-25 22:55:48 +01:00
TITLE: ISQL extract command looses COMPUTED BY field types
DESCRIPTION:
Test creates database with empty table T1 that has computed by fileds with DDL appopriate to the ticket issues.
Then we:
1) extract metadata from database and store it to <init_meta.sql>;
2) run query to the table T1 with setting sqlda_display = ON, and store output to <init_sqlda.log>;
3) DROP table T1;
4) try to apply script with extracted metadata (see step "1") - it should pass without errors;
5) AGAIN extract metadata and store it to <last_meta.sql>;
6) AGAIN run query to T1 with set sqlda_display = on, and store output to <last_sqlda.log>;
7) compare text files:
<init_meta.sql> vs <last_meta.sql>
<init_sqlda.log> vs <last_sqlda.log>
8) Check that result of comparison is EMPTY (no rows).
JIRA: CORE-5092
FBTEST: bugs.core_5092
2022-01-25 22:55:48 +01:00
"""
2021-04-26 20:07:00 +02:00
import pytest
2021-11-29 20:54:28 +01:00
from difflib import unified_diff
2022-01-25 22:55:48 +01:00
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
init_script = """
2021-04-26 20:07:00 +02:00
recreate table t1 (
n0 int
,si smallint computed by( 32767 )
,bi bigint computed by ( 2147483647 )
,s2 smallint computed by ( mod(bi, nullif(si,0)) )
,dv double precision computed by (pi())
,fv float computed by (dv*dv)
,nv numeric(3,1) computed by (sqrt(fv))
,dt date computed by ('now')
,tm time computed by ('now')
,dx timestamp computed by ( dt )
,tx timestamp computed by ( tm )
2021-11-29 20:54:28 +01:00
2021-04-26 20:07:00 +02:00
,c1 char character set win1251 computed by ('ы')
,c2 char character set win1252 computed by ('å')
,cu char character set utf8 computed by ('')
2021-11-29 20:54:28 +01:00
2021-04-26 20:07:00 +02:00
,c1x char computed by(c1)
,c2x char computed by(c2)
,cux char computed by(cu)
2021-11-29 20:54:28 +01:00
2021-04-26 20:07:00 +02:00
,b1 blob character set win1251 computed by ('ы')
,b2 blob character set win1252 computed by ('ä')
,bu blob character set utf8 computed by ('')
,bb blob computed by ('')
2021-11-29 20:54:28 +01:00
2021-04-26 20:07:00 +02:00
,b1x blob computed by (b1)
,b2x blob computed by (b2)
,bux blob computed by (bu)
,bbx blob computed by (bb)
2021-11-29 20:54:28 +01:00
);
2021-04-26 20:07:00 +02:00
--insert into t1 values(null);
2021-11-29 20:54:28 +01:00
commit;
"""
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
db = db_factory(charset='UTF8', init=init_script)
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
act = python_act('db')
2021-04-26 20:07:00 +02:00
2021-11-29 20:54:28 +01:00
@pytest.mark.version('>=3.0')
2022-01-25 22:55:48 +01:00
def test_1(act: Action):
2021-11-29 20:54:28 +01:00
# Initial metadata
2022-01-25 22:55:48 +01:00
act.isql(switches=['-x'])
initial_metadata = act.stdout.splitlines()
2021-11-29 20:54:28 +01:00
# SQLDA initial
sqlda_check = 'set list on; set sqlda_display on; select * from t1; commit; drop table t1; exit;'
2022-01-25 22:55:48 +01:00
act.reset()
act.isql(switches=['-q', '-m'], input=sqlda_check)
initial_sqlda = act.stdout.splitlines()
2021-11-29 20:54:28 +01:00
# Apply extracted metadata
2022-01-25 22:55:48 +01:00
act.reset()
act.isql(switches=[], input='\n'.join(initial_metadata), combine_output = True)
2021-11-29 20:54:28 +01:00
# New metadata
2022-01-25 22:55:48 +01:00
act.reset()
act.isql(switches=['-x'])
new_metadata = act.stdout.splitlines()
2021-11-29 20:54:28 +01:00
# SQLDA new
2022-01-25 22:55:48 +01:00
act.reset()
act.isql(switches=['-q', '-m'], input=sqlda_check, combine_output = True)
2022-01-25 22:55:48 +01:00
new_sqlda = act.stdout.splitlines()
2021-11-29 20:54:28 +01:00
# Check
assert list(unified_diff(initial_sqlda, new_sqlda)) == []
assert list(unified_diff(initial_metadata, new_metadata)) == []