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

111 lines
3.1 KiB
Python
Raw Permalink Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-20 17:32:14 +01:00
"""
ID: issue-2426
ISSUE: 2426
TITLE: UTF8 UNICODE_CI collate can´t be used in foreing key constraint
DESCRIPTION:
JIRA: CORE-1989
FBTEST: bugs.core_1989
2022-01-20 17:32:14 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
init_script = """-- Domains
2021-04-26 20:07:00 +02:00
CREATE DOMAIN INT64 AS
BIGINT;
CREATE DOMAIN VARCHAR100 AS
VARCHAR(100)
COLLATE UNICODE_CI;
CREATE DOMAIN VARCHAR100_CS AS
VARCHAR(100)
COLLATE UNICODE;
CREATE DOMAIN VARCHAR30 AS
VARCHAR(30)
COLLATE UNICODE_CI;
CREATE DOMAIN VARCHAR30_CS AS
VARCHAR(30)
COLLATE UNICODE;
-- Tables
CREATE TABLE ROLES (
ROLE_NAME VARCHAR30 NOT NULL,
APPLICATION_NAME VARCHAR100 NOT NULL
);
CREATE TABLE ROLES_CS (
ROLE_NAME VARCHAR30_CS NOT NULL,
APPLICATION_NAME VARCHAR100_CS NOT NULL
);
CREATE TABLE USERS (
USER_NAME VARCHAR100 NOT NULL,
APPLICATION_NAME VARCHAR100 NOT NULL
);
CREATE TABLE USERS_CS (
USER_NAME VARCHAR100_CS NOT NULL,
APPLICATION_NAME VARCHAR100_CS NOT NULL
);
CREATE TABLE USERS_IN_ROLES (
USER_NAME VARCHAR100 NOT NULL,
ROLE_NAME VARCHAR30 NOT NULL,
APPLICATION_NAME VARCHAR100 NOT NULL
);
CREATE TABLE USERS_IN_ROLES_CS (
USER_NAME VARCHAR100_CS NOT NULL,
ROLE_NAME VARCHAR30_CS NOT NULL,
APPLICATION_NAME VARCHAR100_CS NOT NULL
);
-- Primary Keys
ALTER TABLE ROLES ADD CONSTRAINT PK_ROLES PRIMARY KEY (ROLE_NAME, APPLICATION_NAME);
ALTER TABLE ROLES_CS ADD CONSTRAINT PK_ROLES_CS PRIMARY KEY (ROLE_NAME, APPLICATION_NAME);
ALTER TABLE USERS ADD CONSTRAINT PK_USERS PRIMARY KEY (USER_NAME, APPLICATION_NAME);
ALTER TABLE USERS_CS ADD CONSTRAINT PK_USERS_CS PRIMARY KEY (USER_NAME, APPLICATION_NAME);
-- Foreign Keys
ALTER TABLE USERS_IN_ROLES ADD CONSTRAINT FK_USERS_IN_ROLES_ROLES FOREIGN KEY (ROLE_NAME, APPLICATION_NAME) REFERENCES ROLES (ROLE_NAME, APPLICATION_NAME) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE USERS_IN_ROLES ADD CONSTRAINT FK_USERS_IN_ROLES_USERS FOREIGN KEY (USER_NAME, APPLICATION_NAME) REFERENCES USERS (USER_NAME, APPLICATION_NAME) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE USERS_IN_ROLES_CS ADD CONSTRAINT FK_USERS_IN_ROLES_ROLES_CS FOREIGN KEY (ROLE_NAME, APPLICATION_NAME) REFERENCES ROLES_CS (ROLE_NAME, APPLICATION_NAME) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE USERS_IN_ROLES_CS ADD CONSTRAINT FK_USERS_IN_ROLES_USERS_CS FOREIGN KEY (USER_NAME, APPLICATION_NAME) REFERENCES USERS_CS (USER_NAME, APPLICATION_NAME) ON DELETE CASCADE ON UPDATE CASCADE;
"""
2022-01-20 17:32:14 +01:00
db = db_factory(charset='UTF8', init=init_script)
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
test_script = """insert into USERS(USER_NAME, APPLICATION_NAME) values('User', 'App');
2021-04-26 20:07:00 +02:00
insert into USERS_CS(USER_NAME, APPLICATION_NAME) values('User', 'App');
insert into ROLES(ROLE_NAME, APPLICATION_NAME) values('Role', 'App');
insert into ROLES_CS(ROLE_NAME, APPLICATION_NAME) values('Role', 'App');
commit;
insert into USERS_IN_ROLES_CS(USER_NAME, ROLE_NAME, APPLICATION_NAME) values('User', 'Role', 'App');
commit;
-- Raises error
insert into USERS_IN_ROLES(USER_NAME, ROLE_NAME, APPLICATION_NAME) values('User', 'Role', 'App');
commit;
"""
2022-01-20 17:32:14 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-20 17:32:14 +01:00
@pytest.mark.version('>=3.0')
def test_1(act: Action):
2022-01-25 22:55:48 +01:00
act.execute()