Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加字符集和排序规则的限制 #1607

Open
bdper0 opened this issue Jun 26, 2023 · 7 comments
Open

增加字符集和排序规则的限制 #1607

bdper0 opened this issue Jun 26, 2023 · 7 comments

Comments

@bdper0
Copy link

bdper0 commented Jun 26, 2023

Database Type

Rule Description

Why

@bdper0
Copy link
Author

bdper0 commented Jun 26, 2023

增加规则:
create/alter 表或字段时允许的Collate范围。多个请使用逗号进行分割
create/alter 表或字段时允许的Charset范围。多个请使用逗号进行分割

why:
SQLE 必须使用指定数据库字符集 规则强制所有DDL SQL都必须使用字符集,增加书写难度。

参照yearning 审核规则:
希望实现:

  1. ddl sql 如果带有字符集和排序规则,只能用到相关配置值。
  2. ddl sql也可以不强制带字符集和排序规则。

附件是yearning相关规则及测试。
alter_error
alter_normal1
alter_normal2
create_error
create_normal1
create_normal2
rule

@bdper0
Copy link
Author

bdper0 commented Jun 26, 2023

Database Type: MySQL

@ColdWaterLW
Copy link
Collaborator

能举个实际的使用场景吗?

@sjjian
Copy link
Member

sjjian commented Jun 26, 2023

是指一个项目里可以混用多个字符集和排序规则吗

@bdper0
Copy link
Author

bdper0 commented Jul 7, 2023

能举个实际的使用场景吗?

  1. DDL可以不指定字符集和排序规则,默认以database级别为准
  2. DDL如果要指定字符集和排序规则,只能指定审核规则中配置的字符集和排序规则

@bdper0
Copy link
Author

bdper0 commented Jul 7, 2023

是指一个项目里可以混用多个字符集和排序规则吗

不是混用。
SQLE目前的审核规则 必须使用指定数据库字符集 开启后所有的DDL语句都要指定字符集。

@bdper0 bdper0 closed this as completed Jul 7, 2023
@bdper0 bdper0 reopened this Jul 7, 2023
@bdper0
Copy link
Author

bdper0 commented Jul 7, 2023

能举个实际的使用场景吗?

如配置xxx规则 字符集只能指定utf8mb4
审核通过场景:
create:
CREATE TABLE IF NOT EXISTS test1
(
id bigint(20) NOT NULL COMMENT 'Primary key',
a_code varchar(512) DEFAULT NULL COMMENT 'The unique code of the file',
PRIMARY KEY (id) USING BTREE
);

CREATE TABLE IF NOT EXISTS test1
(
id bigint(20) NOT NULL COMMENT 'Primary key',
a_code varchar(512) DEFAULT NULL COMMENT 'The unique code of the file',
PRIMARY KEY (id) USING BTREE
) DEFAULT CHARSET=utf8mb4;

alter:
alter table test1 add col_b varchar(50) NOT NULL COMMENT 'col_b';
alter table test1 add col_b varchar(50) CHARACTER SET utf8mb4 NOT NULL COMMENT 'col_b';

审核不通过场景:
create:
CREATE TABLE IF NOT EXISTS test1
(
id bigint(20) NOT NULL COMMENT 'Primary key',
a_code varchar(512) DEFAULT NULL COMMENT 'The unique code of the file',
PRIMARY KEY (id) USING BTREE
) DEFAULT CHARSET=utf8;

alter:
alter table test1 add col_b varchar(50) CHARACTER SET utf8 NOT NULL COMMENT 'col_b';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants