Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore(sql-review): add i18n for mysql disallow trigger (#10673)

boojackd21188a6bd7a
diff --git a/backend/plugin/advisor/config/sql-review.dev.yaml b/backend/plugin/advisor/config/sql-review.dev.yaml
index 9207116980..cb76f57ccd 100644
--- a/backend/plugin/advisor/config/sql-review.dev.yaml
+++ b/backend/plugin/advisor/config/sql-review.dev.yaml
@@ -12,6 +12,8 @@ ruleList:
format: _del$
- type: table.disallow-partition
level: ERROR
+ - type: table.disallow-trigger
+ level: ERROR
- type: table.comment
level: WARNING
payload:
diff --git a/backend/plugin/advisor/config/sql-review.prod.yaml b/backend/plugin/advisor/config/sql-review.prod.yaml
index 8a79e8c0fb..dac0b3bd42 100644
--- a/backend/plugin/advisor/config/sql-review.prod.yaml
+++ b/backend/plugin/advisor/config/sql-review.prod.yaml
@@ -12,6 +12,8 @@ ruleList:
format: _del$
- type: table.disallow-partition
level: ERROR
+ - type: table.disallow-trigger
+ level: ERROR
- type: table.comment
level: ERROR
payload:
diff --git a/backend/plugin/advisor/sql_review.go b/backend/plugin/advisor/sql_review.go
index 03f2071d32..c497e65321 100644
--- a/backend/plugin/advisor/sql_review.go
+++ b/backend/plugin/advisor/sql_review.go
@@ -1292,8 +1292,7 @@ func getAdvisorTypeByRule(ruleType SQLReviewRuleType, engine storepb.Engine) (Ty
return PostgreSQLTableDisallowPartition, nil
}
case SchemaRuleTableDisallowTrigger:
- switch engine {
- case storepb.Engine_MYSQL, storepb.Engine_MARIADB:
+ if engine == storepb.Engine_MYSQL {
return MySQLTableDisallowTrigger, nil
}
case SchemaRuleMySQLEngine:
diff --git a/frontend/src/components/Issue/const.ts b/frontend/src/components/Issue/const.ts
index 0d524bfa0a..bb92d91237 100644
--- a/frontend/src/components/Issue/const.ts
+++ b/frontend/src/components/Issue/const.ts
@@ -55,6 +55,7 @@ export const LocalizedSQLRuleErrorCodes = new Set<number>([
SQLReviewPolicyErrorCode.TABLE_EXISTS,
SQLReviewPolicyErrorCode.CREATE_TABLE_PARTITION,
SQLReviewPolicyErrorCode.TABLE_IS_REFERENCED_BY_VIEW,
+ SQLReviewPolicyErrorCode.CREATE_TABLE_TRIGGER,
SQLReviewPolicyErrorCode.DATABASE_NOT_EMPTY,
SQLReviewPolicyErrorCode.NOT_CURRENT_DATABASE,
SQLReviewPolicyErrorCode.DATABASE_IS_DELETED,
diff --git a/frontend/src/locales/sql-review/en-US.json b/frontend/src/locales/sql-review/en-US.json
index 7ebc7280ca..c6e7da73ed 100644
--- a/frontend/src/locales/sql-review/en-US.json
+++ b/frontend/src/locales/sql-review/en-US.json
@@ -56,6 +56,10 @@
"title": "Prohibit using partition table",
"description": "In some database engines, partitioned tables are not mature, and the use and maintenance are inconvenient. Therefore, it is more inclined to use manual data partitioning methods such as database and table sharding. Suggestion error level: Warning"
},
+ "table-disallow-trigger": {
+ "title": "Prevent the use of triggers on tables",
+ "description": "This rule restricts the usage of triggers on tables. Triggers can introduce complexity and potential performance issues to database operations. By disallowing triggers, the system can maintain a simpler and more predictable behavior. Suggestion error level: Warning"
+ },
"table-comment": {
"title": "Comment convention",
"description": "Configure whether the table requires comments and the maximum comment length.",
diff --git a/frontend/src/locales/sql-review/es-ES.json b/frontend/src/locales/sql-review/es-ES.json
index ffeb0a4ea9..5f3c1e621a 100644
--- a/frontend/src/locales/sql-review/es-ES.json
+++ b/frontend/src/locales/sql-review/es-ES.json
@@ -56,6 +56,10 @@
"title": "Prohibir el uso de tablas particionadas",
"description": "En algunos motores de base de datos, las tablas particionadas no están maduras y el uso y mantenimiento son incómodos. Por lo tanto, es más propenso a utilizar métodos manuales de partición de datos como la fragmentación de bases de datos y tablas. Nivel de sugerencia de error: Advertencia"
},
+ "table-disallow-trigger": {
+ "title": "Prohibir el uso de desencadenadores en tablas",
+ "description": "Los desencadenadores pueden hacer que el flujo de control sea difícil de seguir y aumentar la complejidad del sistema. En lugar de usar desencadenadores, se recomienda utilizar la lógica de la aplicación para realizar operaciones de base de datos. Nivel de sugerencia de error: Advertencia"
+ },
"table-comment": {
"title": "Convención de comentarios de tabla",
"description": "Configure si la tabla requiere comentarios y la longitud máxima de comentarios.",
diff --git a/frontend/src/locales/sql-review/ja-JP.json b/frontend/src/locales/sql-review/ja-JP.json
index 3100217af2..b945de0a56 100644
--- a/frontend/src/locales/sql-review/ja-JP.json
+++ b/frontend/src/locales/sql-review/ja-JP.json
@@ -56,6 +56,10 @@
"title": "パーティションテーブルの使用を禁止する",
"description": "一部のデータベースエンジンでは、パーティションテーブルは未熟であり、使用やメンテナンスが不便です。そのため、データベースやテーブルのシャーディングなどの手動のデータパーティショニング方法の使用がより好まれます。提案エラーレベル:警告"
},
+ "table-disallow-trigger": {
+ "title": "テーブルにトリガの使用を禁止する",
+ "description": "トリガはデータベースの複雑さを増加させ、データの整合性を保つための手段としては適切ではありません。代わりに、アプリケーションレイヤーでデータの整合性を保つことをお勧めします。提案エラーレベル:警告"
+ },
"table-comment": {
"title": "コメントの規約",
"description": "テーブルにコメントが必要かどうか、および最大コメント長を設定します。",
diff --git a/frontend/src/locales/sql-review/vi-VN.json b/frontend/src/locales/sql-review/vi-VN.json
index 6ae0dd06cf..5eabae3fe9 100644
--- a/frontend/src/locales/sql-review/vi-VN.json
+++ b/frontend/src/locales/sql-review/vi-VN.json
@@ -56,6 +56,10 @@
"title": "Cấm sử dụng bảng phân vùng",
"description": "Trong một số công cụ cơ sở dữ liệu, các bảng phân vùng chưa hoàn thiện và việc sử dụng cũng như bảo trì rất bất tiện. Do đó, người ta có xu hướng sử dụng các phương pháp phân vùng dữ liệu thủ công như cơ sở dữ liệu và phân chia bảng. Mức độ lỗi đề xuất: Cảnh báo"
},
+ "table-disallow-trigger": {
+ "title": "Cấm sử dụng cơ chế kích hoạt",
+ "description": "Cơ chế kích hoạt có thể gây ra sự không thống nhất dữ liệu và làm giảm hiệu suất. Mức độ lỗi đề xuất: Lỗi"
+ },
"table-comment": {
"title": "quy ước bình luận",
"description": "Định cấu hình xem bảng có yêu cầu nhận xét hay không và độ dài nhận xét tối đa.",
diff --git a/frontend/src/locales/sql-review/zh-CN.json b/frontend/src/locales/sql-review/zh-CN.json
index f6ba07bf9b..8950e094b5 100644
--- a/frontend/src/locales/sql-review/zh-CN.json
+++ b/frontend/src/locales/sql-review/zh-CN.json
@@ -57,6 +57,10 @@
"title": "禁止使用分区表",
"description": "在一些数据库引擎中,分区表技术并不成熟,使用与维护都较为不便,因此更倾向于通过分库分表等方式进行人工数据分区。建议错误等级:警告"
},
+ "table-disallow-trigger": {
+ "title": "禁止使用触发器",
+ "description": "触发器可能导致数据库的隐式行为,增加数据库的复杂性,降低可维护性。建议错误等级:警告"
+ },
"table-comment": {
"title": "注释检查",
"description": "配置表是否需要注释和最大注释长度。",
diff --git a/frontend/src/types/error.ts b/frontend/src/types/error.ts
index 36b0185894..4124fc2d6a 100644
--- a/frontend/src/types/error.ts
+++ b/frontend/src/types/error.ts
@@ -77,6 +77,7 @@ export enum SQLReviewPolicyErrorCode {
TABLE_EXISTS = 607,
CREATE_TABLE_PARTITION = 608,
TABLE_IS_REFERENCED_BY_VIEW = 609,
+ CREATE_TABLE_TRIGGER = 610,
DATABASE_NOT_EMPTY = 701,
NOT_CURRENT_DATABASE = 702,
DATABASE_IS_DELETED = 703,
diff --git a/frontend/src/types/sql-review-schema.yaml b/frontend/src/types/sql-review-schema.yaml
index 7223addbde..90d71f0e46 100644
--- a/frontend/src/types/sql-review-schema.yaml
+++ b/frontend/src/types/sql-review-schema.yaml
@@ -81,6 +81,11 @@ ruleList:
- OCEANBASE
- MARIADB
componentList: []
+ - type: table.disallow-trigger
+ category: TABLE
+ engineList:
+ - MYSQL
+ componentList: []
- type: statement.select.no-select-all
category: STATEMENT
engineList:
diff --git a/frontend/src/types/sqlAdviceCode.ts b/frontend/src/types/sqlAdviceCode.ts
index f6af15eac6..ee4b40803d 100644
--- a/frontend/src/types/sqlAdviceCode.ts
+++ b/frontend/src/types/sqlAdviceCode.ts
@@ -97,6 +97,7 @@ export enum SQLAdviceCodeTable {
TableCommentTooLong = 606,
TableExists = 607,
CreateTablePartition = 608,
+ CreateTableTrigger = 610,
}
// 701 ~ 799 database advisor error code.
diff --git a/frontend/src/types/sqlReview.ts b/frontend/src/types/sqlReview.ts
index 819758b373..edd4b67877 100644
--- a/frontend/src/types/sqlReview.ts
+++ b/frontend/src/types/sqlReview.ts
@@ -103,6 +103,7 @@ export type RuleType =
| "table.no-foreign-key"
| "table.drop-naming-convention"
| "table.disallow-partition"
+ | "table.disallow-trigger"
| "table.comment"
| "naming.table"
| "naming.column"