Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: update sql review rules for PG (#2134)
ecmadao6614bb434d63
diff --git a/frontend/src/locales/sql-review/en-US.json b/frontend/src/locales/sql-review/en-US.jsonindex aa1a730315..9ce8c10dc1 100644--- a/frontend/src/locales/sql-review/en-US.json+++ b/frontend/src/locales/sql-review/en-US.json@@ -47,7 +47,7 @@"title": "Table name format (regex)"},"maxLength": {- "title": "Length limit"+ "title": "Length limit (PostgreSQL is not supported)"}}},@@ -59,7 +59,7 @@"title": "Column name format (regex)"},"maxLength": {- "title": "Length limit"+ "title": "Length limit (PostgreSQL is not supported)"}}},@@ -75,13 +75,13 @@}},"maxLength": {- "title": "Length limit"+ "title": "Length limit (PostgreSQL is not supported)"}}},"naming-index-pk": {"title": "Primary key naming check",- "description": "Enforce the primary key name format and length limit. Default uk_<table_name>_<column_list> with 64 characters.",+ "description": "Enforce the primary key name format and length limit. Default pk_<table_name>_<column_list>.","component": {"format": {"title": "Primary key name format",@@ -89,9 +89,6 @@"table": "The table name","column_list": "Index column names, joined by _"}- },- "maxLength": {- "title": "Length limit"}}},@@ -109,7 +106,7 @@}},"maxLength": {- "title": "Length limit"+ "title": "Length limit (PostgreSQL is not supported)"}}},@@ -125,7 +122,7 @@}},"maxLength": {- "title": "Length limit"+ "title": "Length limit (PostgreSQL is not supported)"}}},diff --git a/frontend/src/locales/sql-review/zh-CN.json b/frontend/src/locales/sql-review/zh-CN.jsonindex f7c3602f37..258ce106ee 100644--- a/frontend/src/locales/sql-review/zh-CN.json+++ b/frontend/src/locales/sql-review/zh-CN.json@@ -47,7 +47,7 @@"title": "表命名规则(正则)"},"maxLength": {- "title": "长度限制"+ "title": "长度限制(暂不支持 PostgreSQL)"}}},@@ -59,7 +59,7 @@"title": "列命名规则(正则)"},"maxLength": {- "title": "长度限制"+ "title": "长度限制(暂不支持 PostgreSQL)"}}},@@ -75,13 +75,13 @@}},"maxLength": {- "title": "长度限制"+ "title": "长度限制(暂不支持 PostgreSQL)"}}},"naming-index-pk": {"title": "主键命名检查",- "description": "限制主键命名风格和长度,默认为 pk_<表名>_<主键包含的字段名组合>,且不超过 64 个字符。",+ "description": "限制主键命名风格和长度,默认为 pk_<表名>_<主键包含的字段名组合>。","component": {"format": {"title": "主键命名规则",@@ -89,9 +89,6 @@"table": "表名","column_list": "索引包含的字段名,通过 _ 连接"}- },- "maxLength": {- "title": "长度限制"}}},@@ -109,7 +106,7 @@}},"maxLength": {- "title": "长度限制"+ "title": "长度限制(暂不支持 PostgreSQL)"}}},@@ -125,7 +122,7 @@}},"maxLength": {- "title": "长度限制"+ "title": "长度限制(暂不支持 PostgreSQL)"}}},diff --git a/frontend/src/types/sql-review-schema.yaml b/frontend/src/types/sql-review-schema.yamlindex 00c0e77744..7de6d98afc 100644--- a/frontend/src/types/sql-review-schema.yaml+++ b/frontend/src/types/sql-review-schema.yaml@@ -11,7 +11,6 @@ ruleList:category: ENGINEengineList:- MYSQL- - TIDBcomponentList: []- type: table.require-pkcategory: TABLE@@ -155,10 +154,6 @@ ruleList:templateList:- table- column_list- - key: maxLength- payload:- type: NUMBER- default: 64- type: column.requiredcategory: COLUMNengineList:diff --git a/frontend/src/types/sqlReview.ts b/frontend/src/types/sqlReview.tsindex 7f977d9f77..314690862c 100644--- a/frontend/src/types/sqlReview.ts+++ b/frontend/src/types/sqlReview.ts@@ -312,9 +312,25 @@ export const convertPolicyRuleToRuleTemplate = (},],};+ case "naming.index.pk":+ if (!templateComponent) {+ throw new Error(`Invalid rule ${ruleTemplate.type}`);+ }++ return {+ ...res,+ componentList: [+ {+ ...templateComponent,+ payload: {+ ...templateComponent.payload,+ value: (policyRule.payload as NamingFormatPayload).format,+ } as TemplatePayload,+ },+ ],+ };case "naming.index.idx":case "naming.index.uk":- case "naming.index.pk":case "naming.index.fk":if (!templateComponent || !numberComponent) {throw new Error(`Invalid rule ${ruleTemplate.type}`);@@ -408,9 +424,18 @@ export const convertRuleTemplateToPolicyRule = (maxLength: numberPayload.value ?? numberPayload.default,},};+ case "naming.index.pk":+ if (!templatePayload) {+ throw new Error(`Invalid rule ${rule.type}`);+ }+ return {+ ...base,+ payload: {+ format: templatePayload.value ?? templatePayload.default,+ },+ };case "naming.index.idx":case "naming.index.uk":- case "naming.index.pk":case "naming.index.fk":if (!templatePayload || !numberPayload) {throw new Error(`Invalid rule ${rule.type}`);