From 2623d729e84ab999772d05078c906b456c0f7d28 Mon Sep 17 00:00:00 2001 From: iwanghc Date: Wed, 6 Nov 2024 17:59:40 +0800 Subject: [PATCH 1/2] =?UTF-8?q?chore=EF=BC=9Adatabase=20comparison=20sql?= =?UTF-8?q?=20statement=20returns=20if=20an=20audit=20error=20occurs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sqle/api/controller/v1/database_compare.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sqle/api/controller/v1/database_compare.go b/sqle/api/controller/v1/database_compare.go index 2083f1527..4b8bd7999 100644 --- a/sqle/api/controller/v1/database_compare.go +++ b/sqle/api/controller/v1/database_compare.go @@ -70,13 +70,18 @@ type DatabaseComparisonStatementsResV1 struct { } type DatabaseComparisonStatements struct { - BaseSQL *SQLStatementWithAuditResult `json:"base_sql"` - ComparisondSQL *SQLStatementWithAuditResult `json:"comparison_sql"` + BaseSQL *SQLStatement `json:"base_sql"` + ComparisondSQL *SQLStatement `json:"comparison_sql"` +} + +type SQLStatement struct { + AuditError string `json:"audit_error,omitempty"` + SQLStatementWithAudit *SQLStatementWithAuditResult `json:"sql_statement_with_audit"` } type SQLStatementWithAuditResult struct { SQLStatement string `json:"sql_statement"` - AuditResults []*SQLAuditResult `json:"audit_results"` + AuditResults []*SQLAuditResult `json:"audit_results,omitempty"` } type SQLAuditResult struct { @@ -122,6 +127,7 @@ type GenModifySQLResV1 struct { type DatabaseDiffModifySQL struct { SchemaName string `json:"schema_name"` ModifySQLs []*SQLStatementWithAuditResult `json:"modify_sqls"` + AuditError string `json:"audit_error,omitempty"` } // @Summary 生成变更SQL From 6f07737a2d2eef69ddf49581fff2777309d1f0a8 Mon Sep 17 00:00:00 2001 From: iwanghc Date: Wed, 6 Nov 2024 17:59:59 +0800 Subject: [PATCH 2/2] gen swagger: add db comparison audit error result --- sqle/docs/docs.go | 19 +++++++++++++++++-- sqle/docs/swagger.json | 19 +++++++++++++++++-- sqle/docs/swagger.yaml | 14 ++++++++++++-- 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/sqle/docs/docs.go b/sqle/docs/docs.go index a99ba6240..e9af729cf 100644 --- a/sqle/docs/docs.go +++ b/sqle/docs/docs.go @@ -12219,11 +12219,11 @@ var doc = `{ "properties": { "base_sql": { "type": "object", - "$ref": "#/definitions/v1.SQLStatementWithAuditResult" + "$ref": "#/definitions/v1.SQLStatement" }, "comparison_sql": { "type": "object", - "$ref": "#/definitions/v1.SQLStatementWithAuditResult" + "$ref": "#/definitions/v1.SQLStatement" } } }, @@ -12247,6 +12247,9 @@ var doc = `{ "v1.DatabaseDiffModifySQL": { "type": "object", "properties": { + "audit_error": { + "type": "string" + }, "modify_sqls": { "type": "array", "items": { @@ -16104,6 +16107,18 @@ var doc = `{ } } }, + "v1.SQLStatement": { + "type": "object", + "properties": { + "audit_error": { + "type": "string" + }, + "sql_statement_with_audit": { + "type": "object", + "$ref": "#/definitions/v1.SQLStatementWithAuditResult" + } + } + }, "v1.SQLStatementWithAuditResult": { "type": "object", "properties": { diff --git a/sqle/docs/swagger.json b/sqle/docs/swagger.json index 371f769ce..fd0cce2d4 100644 --- a/sqle/docs/swagger.json +++ b/sqle/docs/swagger.json @@ -12203,11 +12203,11 @@ "properties": { "base_sql": { "type": "object", - "$ref": "#/definitions/v1.SQLStatementWithAuditResult" + "$ref": "#/definitions/v1.SQLStatement" }, "comparison_sql": { "type": "object", - "$ref": "#/definitions/v1.SQLStatementWithAuditResult" + "$ref": "#/definitions/v1.SQLStatement" } } }, @@ -12231,6 +12231,9 @@ "v1.DatabaseDiffModifySQL": { "type": "object", "properties": { + "audit_error": { + "type": "string" + }, "modify_sqls": { "type": "array", "items": { @@ -16088,6 +16091,18 @@ } } }, + "v1.SQLStatement": { + "type": "object", + "properties": { + "audit_error": { + "type": "string" + }, + "sql_statement_with_audit": { + "type": "object", + "$ref": "#/definitions/v1.SQLStatementWithAuditResult" + } + } + }, "v1.SQLStatementWithAuditResult": { "type": "object", "properties": { diff --git a/sqle/docs/swagger.yaml b/sqle/docs/swagger.yaml index dcf888a63..0437c540e 100644 --- a/sqle/docs/swagger.yaml +++ b/sqle/docs/swagger.yaml @@ -987,10 +987,10 @@ definitions: v1.DatabaseComparisonStatements: properties: base_sql: - $ref: '#/definitions/v1.SQLStatementWithAuditResult' + $ref: '#/definitions/v1.SQLStatement' type: object comparison_sql: - $ref: '#/definitions/v1.SQLStatementWithAuditResult' + $ref: '#/definitions/v1.SQLStatement' type: object type: object v1.DatabaseComparisonStatementsResV1: @@ -1007,6 +1007,8 @@ definitions: type: object v1.DatabaseDiffModifySQL: properties: + audit_error: + type: string modify_sqls: items: $ref: '#/definitions/v1.SQLStatementWithAuditResult' @@ -3644,6 +3646,14 @@ definitions: query_timeout_second: type: integer type: object + v1.SQLStatement: + properties: + audit_error: + type: string + sql_statement_with_audit: + $ref: '#/definitions/v1.SQLStatementWithAuditResult' + type: object + type: object v1.SQLStatementWithAuditResult: properties: audit_results: