6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 21:43:06 +01:00
firebird-qa/tests/bugs/core_2531_test.py

63 lines
1.9 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-21 18:49:26 +01:00
"""
ID: issue-2941
ISSUE: 2941
TITLE: The famous "cannot transliterate" error may be thrown when selecting data from the monitoring tables
DESCRIPTION:
JIRA: CORE-2531
FBTEST: bugs.core_2531
2022-01-21 18:49:26 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
init_script = """
2021-11-16 19:44:53 +01:00
recreate table non_ascii(stored_sql_expr varchar(255) character set win1252);
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
db = db_factory(init=init_script, charset='WIN1252')
test_script = """
set count on;
set blob all;
set list on;
select stored_sql_expr from non_ascii;
select
c.rdb$character_set_name as connection_charset
,s.mon$sql_text as sql_text_blob_id
from mon$attachments a
left join rdb$character_sets c on a.mon$character_set_id = c.rdb$character_set_id
left join mon$statements s on a.mon$attachment_id = s.mon$attachment_id
where
s.mon$attachment_id <> current_connection
and s.mon$sql_text containing 'non_ascii_literal'
;
"""
2021-11-16 19:44:53 +01:00
2022-01-21 18:49:26 +01:00
act = python_act('db', substitutions=[('SQL_TEXT_BLOB_ID .*', ''), ('[\t ]+', ' ')])
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
STORED_SQL_EXPR select 'gång' as non_ascii_literal from rdb$database
Records affected: 1
CONNECTION_CHARSET WIN1252
select 'gång' as non_ascii_literal from rdb$database
Records affected: 1
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.intl
2022-01-21 18:49:26 +01:00
@pytest.mark.version('>=3')
def test_1(act: Action):
2021-11-16 19:44:53 +01:00
non_ascii_query = "select 'gång' as non_ascii_literal from rdb$database"
non_ascii_query_inline = non_ascii_query.replace("'","''")
2022-01-21 18:49:26 +01:00
act.expected_stdout = expected_stdout
with act.db.connect(charset='WIN1252') as con:
2021-11-16 19:44:53 +01:00
c = con.cursor()
c.execute(f"insert into non_ascii(stored_sql_expr) values('{non_ascii_query_inline}')")
con.commit()
x = c.prepare(non_ascii_query)
2022-01-21 18:49:26 +01:00
act.isql(switches=[], input=test_script, charset='WIN1252')
assert act.clean_stdout == act.clean_expected_stdout
2021-04-26 20:07:00 +02:00