2023-02-28 08:21:01 +01:00
|
|
|
|
#coding:utf-8
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
ID: issue-7167
|
|
|
|
|
ISSUE: https://github.com/FirebirdSQL/firebird/issues/7167
|
|
|
|
|
TITLE: Incorrect transliteration of field names in constraint violation errors
|
|
|
|
|
DESCRIPTION:
|
|
|
|
|
NOTES:
|
|
|
|
|
[28.02.2023] pzotov
|
2023-03-05 15:50:00 +01:00
|
|
|
|
Confirmed bug on 4.0.1.2692 Windows and Linux.
|
|
|
|
|
NB: on Linux we have to write SQL script into file with encoding = cp1251
|
|
|
|
|
and run it as script, otherwise issue not reproduced.
|
|
|
|
|
|
|
|
|
|
Checked on Windows and Linux, builds 5.0.0.961, 4.0.3.2903 - all OK.
|
2023-02-28 08:21:01 +01:00
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
from firebird.qa import *
|
2023-03-05 15:50:00 +01:00
|
|
|
|
from pathlib import Path
|
|
|
|
|
import time
|
2023-02-28 08:21:01 +01:00
|
|
|
|
|
|
|
|
|
db = db_factory(charset = 'win1251')
|
2023-03-05 15:50:00 +01:00
|
|
|
|
act = python_act('db', substitutions = [('After line \\d+ in file .*', '')])
|
|
|
|
|
tmp_sql = temp_file('tmp_gh_7167.tmp.sql')
|
2023-02-28 08:21:01 +01:00
|
|
|
|
expected_stdout = """
|
|
|
|
|
Statement failed, SQLSTATE = 23000
|
|
|
|
|
violation of PRIMARY or UNIQUE KEY constraint "уни" on table "абв"
|
|
|
|
|
-Problematic key value is ("аб" = 'аб', "вг" = 'аб', "де" = 'аб')
|
|
|
|
|
"""
|
|
|
|
|
@pytest.mark.version('>=4.0.2')
|
2023-03-05 15:50:00 +01:00
|
|
|
|
def test_1(act: Action, tmp_sql: Path):
|
2023-02-28 08:21:01 +01:00
|
|
|
|
test_sql = """
|
|
|
|
|
create table "абв" (
|
|
|
|
|
"аб" varchar(5) character set win1251,
|
|
|
|
|
"вг" varchar(5) character set dos866,
|
|
|
|
|
"де" varchar(5) character set utf8,
|
|
|
|
|
constraint "уни" unique ("аб", "вг", "де")
|
|
|
|
|
);
|
|
|
|
|
insert into "абв" values ('аб','аб','аб');
|
|
|
|
|
insert into "абв" values ('аб','аб','аб');
|
|
|
|
|
"""
|
2023-03-05 15:50:00 +01:00
|
|
|
|
tmp_sql.write_bytes(test_sql.encode('cp1251'))
|
2023-02-28 08:21:01 +01:00
|
|
|
|
act.expected_stdout = expected_stdout
|
2023-03-05 15:50:00 +01:00
|
|
|
|
act.isql(switches=['-q'], charset = 'win1251', input_file = tmp_sql, combine_output = True)
|
2023-02-28 08:21:01 +01:00
|
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|