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

71 lines
2.4 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-6407
ISSUE: 6407
TITLE: substring similar - extra characters in the result for non latin characters
DESCRIPTION:
JIRA: CORE-6158
FBTEST: bugs.core_6158
2022-01-27 20:08:36 +01:00
"""
2021-04-26 20:07:00 +02:00
import pytest
2021-12-14 20:56:34 +01:00
from pathlib import Path
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(charset='WIN1251')
2021-12-14 20:56:34 +01:00
2022-01-27 20:08:36 +01:00
act = python_act('db', substitutions=[('RESULT_3_BLOB_ID.*', '')])
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
RESULT1 = Комментарий между символами "равно" =
RESULT2 - Комментарий между символами "дефис" -
Российский рубль; Турецкая лира; Доллар США
2021-12-14 20:56:34 +01:00
"""
2022-01-27 20:08:36 +01:00
script_file = temp_file('test-script.sql')
pattern_01 = '%/#*(=){3,}#"%#"(=){3,}#*/%'
pattern_02 = '%/#*(#-){3,}#"%#"(#-){3,}#*/%'
test_script = f"""
-- This is needed to get "cannot transliterate character between character sets"
-- on build 4.0.0.1631, see comment in the tracker 18/Oct/19 02:57 PM:
create domain T_A64 as varchar (64) character set WIN1251 collate WIN1251;
create table VALUT_LIST (NAME T_A64 not null);
commit;
insert into VALUT_LIST (NAME) values ('Российский рубль');
insert into VALUT_LIST (NAME) values ('Турецкая лира');
insert into VALUT_LIST (NAME) values ('Доллар США');
commit;
set list on;
set blob all;
select substring('
aaa
/*==== Комментарий между символами "равно" ====*/
bbb
ccc
ddd
eee
fff
jjj
' similar '{pattern_01}' escape '#') as result1
from rdb$database;
-- additional check for special character '-' as delimiter:
select substring('здесь написан /*---- Комментарий между символами "дефис" ----*/ - и больше ничего!' similar '{pattern_02}' escape '#') as result2
from rdb$database;
-- Confirmed fail on 4.0.0.1631 with "cannot transliterate character between character sets":
select substring(list(T.NAME, '; ') from 1 for 250) as result_3_blob_id from VALUT_LIST T;
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=4.0')
2022-01-27 20:08:36 +01:00
def test_1(act: Action, script_file: Path):
script_file.write_text(test_script, encoding='cp1251')
act.expected_stdout = expected_stdout
act.isql(switches=['-q'], input_file=script_file, charset='win1251')
assert act.clean_stdout == act.clean_expected_stdout