6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 13:33:07 +01:00

Added/Updated tests\bugs\core_1366_test.py: Re-implemented. See notes. Checked on 6.0.0.511 (Windows/Linux); 5.0.2.1550; 4.0.6.3165; 3.0.2.32670, 3,0,1,32609

This commit is contained in:
pavel-zotov 2024-10-31 00:54:53 +03:00
parent b64fc14d0e
commit ba89f2888e

View File

@ -1,117 +1,114 @@
#coding:utf-8 #coding:utf-8
""" """
ID: issue-1784 ID: issue-1784
ISSUE: 1784 ISSUE: 1784
TITLE: French insensitive collation FR_FR_CI_AI TITLE: French insensitive collation FR_FR_CI_AI
DESCRIPTION: DESCRIPTION: Add French case-/accent-insensitive collation.
JIRA: CORE-1366 JIRA: CORE-1366
FBTEST: bugs.core_1366 FBTEST: bugs.core_1366
NOTES: NOTES:
[06.10.2022] pzotov [31.10.2024] pzotov
Could not complete adjusting for LINUX in new-qa. Bug was fixed for too old FB (2.1.8), firebird-driver and/or QA-plugin
DEFERRED. will not able to run on this version in order to reproduce problem.
"""
import platform Checked on 6.0.0.511 (Windows/Linux); 5.0.2.1550; 4.0.6.3165; 3.0.2.32670, 3,0,1,32609
import pytest """
from firebird.qa import * from pathlib import Path
init_script = """ import pytest
recreate table test(id int); from firebird.qa import *
commit;
db = db_factory(charset='ISO8859_1')
set term ^; act = isql_act('db', substitutions=[('=.*', ''), ('[ \\t]+', ' ')])
execute block as tmp_sql = temp_file('tmp_core_1366.sql')
begin
begin execute statement 'drop collation coll_fr'; when any do begin end end @pytest.mark.version('>=3.0.0')
end def test_1(act: Action, tmp_sql: Path):
^set term ;^
commit; test_script = f"""
recreate table test(id int);
create collation coll_fr for iso8859_1 from external ('FR_FR') case insensitive accent insensitive; commit;
commit;
set term ^;
recreate table test(id int, cf varchar(10) collate coll_fr); execute block as
commit; begin
begin execute statement 'drop collation coll_fr'; when any do begin end end
recreate table noac(id int, nf varchar(10) collate coll_fr); end
commit; ^set term ;^
commit;
-- http://french.about.com/od/pronunciation/a/accents.htm
create collation coll_fr for iso8859_1 from external ('FR_FR') case insensitive accent insensitive;
-- ### ONCE AGAIN ### commit;
-- 1) for checking this under ISQL following must be encoded in ISO8859_1
-- 2) for running under fbt_run utility following must be encoded in UTF8. recreate table test(id int, cf varchar(10) collate coll_fr);
commit;
-- (cedilla) is found only on the letter "C":
insert into test(id, cf) values( 1010, 'ç'); recreate table noac(id int, nf varchar(10) collate coll_fr);
commit;
-- (acute accent) can only be on an "E"
insert into test(id, cf) values( 1020, 'é'); -- http://french.about.com/od/pronunciation/a/accents.htm
-- (grave accent) can be found on an "A", "E", "U" -- (cedilla) is found only on the letter "C":
insert into test(id, cf) values( 1030, 'à'); insert into test(id, cf) values( 1010, 'ç');
insert into test(id, cf) values( 1040, 'è');
insert into test(id, cf) values( 1050, 'ù'); -- (acute accent) can only be on an "E"
insert into test(id, cf) values( 1020, 'é');
-- (dieresis or umlaut) can be on an E, I and U
insert into test(id, cf) values( 1060, 'ë'); -- (grave accent) can be found on an "A", "E", "U"
insert into test(id, cf) values( 1070, 'ï'); insert into test(id, cf) values( 1030, 'à');
insert into test(id, cf) values( 1080, 'ü'); insert into test(id, cf) values( 1040, 'è');
insert into test(id, cf) values( 1050, 'ù');
-- (circumflex) can be on an A, E, I, O and U
insert into test(id, cf) values( 1090, 'â'); -- (dieresis or umlaut) can be on an E, I and U
insert into test(id, cf) values( 1110, 'ê'); insert into test(id, cf) values( 1060, 'ë');
insert into test(id, cf) values( 1120, 'î'); insert into test(id, cf) values( 1070, 'ï');
insert into test(id, cf) values( 1130, 'û'); insert into test(id, cf) values( 1080, 'ü');
insert into test(id, cf) values( 1140, 'ô');
commit; -- (circumflex) can be on an A, E, I, O and U
insert into test(id, cf) values( 1090, 'â');
-- ANSI letters that should be equal to diacritical insert into test(id, cf) values( 1110, 'ê');
-- when doing comparison CI_AI: insert into test(id, cf) values( 1120, 'î');
insert into noac(id, nf) values( 1150, 'A'); insert into test(id, cf) values( 1130, 'û');
insert into noac(id, nf) values( 1160, 'C'); insert into test(id, cf) values( 1140, 'ô');
insert into noac(id, nf) values( 1170, 'E'); commit;
insert into noac(id, nf) values( 1180, 'I');
insert into noac(id, nf) values( 1190, 'O'); -- ANSI letters that should be equal to diacritical
insert into noac(id, nf) values( 1200, 'U'); -- when doing comparison CI_AI:
commit; insert into noac(id, nf) values( 1150, 'A');
insert into noac(id, nf) values( 1160, 'C');
""" insert into noac(id, nf) values( 1170, 'E');
insert into noac(id, nf) values( 1180, 'I');
db = db_factory(charset='ISO8859_1', init=init_script) insert into noac(id, nf) values( 1190, 'O');
insert into noac(id, nf) values( 1200, 'U');
test_script = """ commit;
select n.id n_id, n.nf, t.cf, t.id t_id select n.id n_id, n.nf, t.cf, t.id t_id
from noac n from noac n
left join test t on n.nf is not distinct from t.cf left join test t on n.nf is not distinct from t.cf
order by n_id, t_id; order by n_id, t_id;
""" """
act = isql_act('db', test_script, substitutions=[('=.*', ''), ('[ \t]+', ' ')]) # https://github.com/FirebirdSQL/firebird/issues/1784#issuecomment-826188088
# ::: NB :::
expected_stdout = """ # For proper output of test, input script must be encoded in ISO8859_1 rather than in UTF-8.
N_ID NF CF T_ID #
============ ========== ========== ============ tmp_sql.write_text(test_script, encoding='iso8859_1')
1150 A à 1030 act.expected_stdout = """
1150 A â 1090 N_ID NF CF T_ID
1160 C ç 1010 ============ ========== ========== ============
1170 E é 1020 1150 A à 1030
1170 E è 1040 1150 A â 1090
1170 E ë 1060 1160 C ç 1010
1170 E ê 1110 1170 E é 1020
1180 I ï 1070 1170 E è 1040
1180 I î 1120 1170 E ë 1060
1190 O ô 1140 1170 E ê 1110
1200 U ù 1050 1180 I ï 1070
1200 U ü 1080 1180 I î 1120
1200 U û 1130 1190 O ô 1140
""" 1200 U ù 1050
1200 U ü 1080
@pytest.mark.skipif(platform.system() != 'Windows', reason='FIXME: see notes') 1200 U û 1130
@pytest.mark.version('>=3') """
def test_1(act: Action): act.isql(switches = ['-q'], input_file = tmp_sql, charset = 'iso8859_1', combine_output = True)
act.expected_stdout = expected_stdout assert act.clean_stdout == act.clean_expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout