2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
"""
|
|
|
|
ID: issue-4331
|
|
|
|
ISSUE: 4331
|
|
|
|
TITLE: Bug in unique constraints and / or NUMERIC-SORT collation
|
|
|
|
DESCRIPTION:
|
|
|
|
JIRA: CORE-3999
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_3999
|
2022-01-22 21:59:15 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
import pytest
|
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
db = db_factory()
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
test_script = """
|
2021-04-26 20:07:00 +02:00
|
|
|
recreate table products(productno char(1));
|
|
|
|
commit;
|
|
|
|
set term ^;
|
|
|
|
execute block as
|
|
|
|
begin
|
|
|
|
execute statement 'drop collation unicode_num_ci_ai';
|
|
|
|
when any do begin end
|
|
|
|
end^
|
|
|
|
set term ;^
|
|
|
|
commit;
|
|
|
|
create collation unicode_num_ci_ai for utf8 from unicode_ci_ai 'numeric-sort=1';
|
|
|
|
recreate table products(productno varchar(100) character set utf8 collate unicode_num_ci_ai);
|
2022-01-22 21:59:15 +01:00
|
|
|
alter table products add constraint uk_products unique (productno) using index uk_products;
|
2021-04-26 20:07:00 +02:00
|
|
|
commit;
|
|
|
|
insert into products values('s01');
|
|
|
|
insert into products values('s1');
|
|
|
|
insert into products values('01');
|
|
|
|
insert into products values('001');
|
|
|
|
insert into products values('-01');
|
|
|
|
insert into products values('-001');
|
|
|
|
commit;
|
|
|
|
set list on;
|
|
|
|
select distinct productno from products;
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
act = isql_act('db', test_script)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
expected_stdout = """
|
2021-04-26 20:07:00 +02:00
|
|
|
PRODUCTNO -001
|
|
|
|
PRODUCTNO -01
|
|
|
|
PRODUCTNO 001
|
|
|
|
PRODUCTNO 01
|
|
|
|
PRODUCTNO s01
|
|
|
|
PRODUCTNO s1
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
@pytest.mark.version('>=3.0')
|
2022-01-22 21:59:15 +01:00
|
|
|
def test_1(act: Action):
|
|
|
|
act.expected_stdout = expected_stdout
|
|
|
|
act.execute()
|
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|
2021-04-26 20:07:00 +02:00
|
|
|
|