Skip to content

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

refactor: deprecate line and column in v1 advice (#15926)

h3n4l9a73f0c4e603
diff --git a/action/azure_devops.go b/action/azure_devops.go
index bfafcfaa0c..74d901ca59 100644
--- a/action/azure_devops.go
+++ b/action/azure_devops.go
@@ -35,7 +35,7 @@ func loggingReleaseChecks(resp *v1pb.CheckReleaseResponse) error {
hasError = true
}
- position := fmt.Sprintf("line %d", common.ConvertLineToActionLine(int(advice.Line)))
+ position := fmt.Sprintf("line %d", common.ConvertLineToActionLine(int(advice.GetStartPosition().GetLine())))
fmt.Printf("* (%s) Code %d - %s (%s): %s\n", advice.Status.String(), advice.Code, advice.Title, position, advice.Content)
}
}
diff --git a/action/bitbucket.go b/action/bitbucket.go
index 93f6060e42..483028aeca 100644
--- a/action/bitbucket.go
+++ b/action/bitbucket.go
@@ -126,7 +126,7 @@ func createBitbucketReport(checkResponse *v1pb.CheckReleaseResponse) error {
Severity: severity,
Result: res,
Path: result.File,
- Line: common.ConvertLineToActionLine(int(advice.Line)),
+ Line: common.ConvertLineToActionLine(int(advice.GetStartPosition().GetLine())),
})
count++
}
diff --git a/action/github/github.go b/action/github/github.go
index 1739a88c69..09d4602247 100644
--- a/action/github/github.go
+++ b/action/github/github.go
@@ -187,7 +187,7 @@ func writeAnnotations(resp *v1pb.CheckReleaseResponse) error {
_, _ = sb.WriteString(" file=")
_, _ = sb.WriteString(result.File)
_, _ = sb.WriteString(",line=")
- _, _ = sb.WriteString(strconv.Itoa(common.ConvertLineToActionLine(int(advice.Line))))
+ _, _ = sb.WriteString(strconv.Itoa(common.ConvertLineToActionLine(int(advice.GetStartPosition().GetLine()))))
_, _ = sb.WriteString(",title=")
_, _ = sb.WriteString(advice.Title)
_, _ = sb.WriteString(" (")
diff --git a/action/gitlab.go b/action/gitlab.go
index a22c196950..719efbddde 100644
--- a/action/gitlab.go
+++ b/action/gitlab.go
@@ -81,12 +81,12 @@ func writeReleaseCheckToCodeQualityJSON(resp *v1pb.CheckReleaseResponse) error {
data = append(data, Finding{
Description: advice.Content,
CheckName: advice.Title,
- Fingerprint: fmt.Sprintf("%s#%d", result.File, advice.Line),
+ Fingerprint: fmt.Sprintf("%s#%d", result.File, advice.GetStartPosition().GetLine()),
Severity: severity,
Location: Location{
Path: result.File,
Lines: Lines{
- Begin: common.ConvertLineToActionLine(int(advice.Line)),
+ Begin: common.ConvertLineToActionLine(int(advice.GetStartPosition().GetLine())),
},
},
})
diff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.go
index c09003803e..3c9d07dbd5 100644
--- a/backend/api/v1/sql_service.go
+++ b/backend/api/v1/sql_service.go
@@ -1649,8 +1649,6 @@ func convertToV1Advice(advice *storepb.Advice) *v1pb.Advice {
Code: int32(advice.Code),
Title: advice.Title,
Content: advice.Content,
- Line: int32(advice.GetStartPosition().GetLine()),
- Column: int32(advice.GetStartPosition().GetColumn()),
StartPosition: convertToPosition(advice.StartPosition),
EndPosition: convertToPosition(advice.EndPosition),
}
diff --git a/frontend/src/components/IssueV1/components/StatementSection/useSQLAdviceMarkers.ts b/frontend/src/components/IssueV1/components/StatementSection/useSQLAdviceMarkers.ts
index d690a2861d..5c316e9bd9 100644
--- a/frontend/src/components/IssueV1/components/StatementSection/useSQLAdviceMarkers.ts
+++ b/frontend/src/components/IssueV1/components/StatementSection/useSQLAdviceMarkers.ts
@@ -20,8 +20,8 @@ export const useSQLAdviceMarkers = (
if (!advices) return [];
if (!advices.value) return [];
return advices.value.map<AdviceOption>((advice) => {
- const line = advice.line;
- const column = advice.column ?? Number.MAX_SAFE_INTEGER;
+ const line = advice.startPosition?.line ?? 0;
+ const column = advice.startPosition?.column ?? Number.MAX_SAFE_INTEGER;
const code = advice.code;
return {
severity: advice.status === Advice_Status.ERROR ? "ERROR" : "WARNING",
diff --git a/frontend/src/components/Plan/components/StatementSection/useSQLAdviceMarkers.ts b/frontend/src/components/Plan/components/StatementSection/useSQLAdviceMarkers.ts
index 2f00ed26ad..318205f7f2 100644
--- a/frontend/src/components/Plan/components/StatementSection/useSQLAdviceMarkers.ts
+++ b/frontend/src/components/Plan/components/StatementSection/useSQLAdviceMarkers.ts
@@ -20,8 +20,8 @@ export const useSQLAdviceMarkers = (
if (!advices) return [];
if (!advices.value) return [];
return advices.value.map<AdviceOption>((advice) => {
- const line = advice.line;
- const column = advice.column ?? Number.MAX_SAFE_INTEGER;
+ const line = advice.startPosition?.line ?? 0;
+ const column = advice.startPosition?.column ?? Number.MAX_SAFE_INTEGER;
const code = advice.code;
return {
severity: advice.status === Advice_Status.ERROR ? "ERROR" : "WARNING",
diff --git a/frontend/src/components/SQLCheck/SQLCheckPanel.vue b/frontend/src/components/SQLCheck/SQLCheckPanel.vue
index 9346d6125b..ab0f50a474 100644
--- a/frontend/src/components/SQLCheck/SQLCheckPanel.vue
+++ b/frontend/src/components/SQLCheck/SQLCheckPanel.vue
@@ -168,8 +168,8 @@ const planCheckRun = computed((): PlanCheckRun => {
code: advice.code,
content: advice.content,
sqlReviewReport: PlanCheckRun_Result_SqlReviewReport.fromPartial({
- line: advice.line,
- column: advice.column,
+ line: advice.startPosition?.line ?? 0,
+ column: advice.startPosition?.column ?? Number.MAX_SAFE_INTEGER,
}),
});
}),
diff --git a/frontend/src/store/modules/v1/sql.ts b/frontend/src/store/modules/v1/sql.ts
index 7f376d230f..7712ed623f 100644
--- a/frontend/src/store/modules/v1/sql.ts
+++ b/frontend/src/store/modules/v1/sql.ts
@@ -23,8 +23,10 @@ const getSqlReviewReports = (err: unknown): Advice[] => {
code: sqlReviewReport.code,
title: sqlReviewReport.title || "SQL Review Failed",
content: sqlReviewReport.content,
- line: sqlReviewReport.sqlReviewReport?.line,
- column: sqlReviewReport.sqlReviewReport?.column,
+ startPosition: {
+ line: sqlReviewReport.sqlReviewReport?.line,
+ column: sqlReviewReport.sqlReviewReport?.column,
+ },
})
);
}
diff --git a/frontend/src/types/proto/v1/sql_service.ts b/frontend/src/types/proto/v1/sql_service.ts
index f35519eef2..f42ad9d069 100644
--- a/frontend/src/types/proto/v1/sql_service.ts
+++ b/frontend/src/types/proto/v1/sql_service.ts
@@ -279,12 +279,7 @@ export interface Advice {
title: string;
/** The advice content. */
content: string;
- /** The advice line number in the SQL statement. */
- line: number;
- /** The advice column number in the SQL statement. */
- column: number;
/**
- * To supersede `line` and `column` above.
* The start_position is inclusive and the end_position is exclusive.
* TODO: use range instead
*/
@@ -2291,8 +2286,6 @@ function createBaseAdvice(): Advice {
code: 0,
title: "",
content: "",
- line: 0,
- column: 0,
startPosition: undefined,
endPosition: undefined,
};
@@ -2312,12 +2305,6 @@ export const Advice: MessageFns<Advice> = {
if (message.content !== "") {
writer.uint32(34).string(message.content);
}
- if (message.line !== 0) {
- writer.uint32(40).int32(message.line);
- }
- if (message.column !== 0) {
- writer.uint32(48).int32(message.column);
- }
if (message.startPosition !== undefined) {
Position.encode(message.startPosition, writer.uint32(66).fork()).join();
}
@@ -2366,22 +2353,6 @@ export const Advice: MessageFns<Advice> = {
message.content = reader.string();
continue;
}
- case 5: {
- if (tag !== 40) {
- break;
- }
-
- message.line = reader.int32();
- continue;
- }
- case 6: {
- if (tag !== 48) {
- break;
- }
-
- message.column = reader.int32();
- continue;
- }
case 8: {
if (tag !== 66) {
break;
@@ -2413,8 +2384,6 @@ export const Advice: MessageFns<Advice> = {
code: isSet(object.code) ? globalThis.Number(object.code) : 0,
title: isSet(object.title) ? globalThis.String(object.title) : "",
content: isSet(object.content) ? globalThis.String(object.content) : "",
- line: isSet(object.line) ? globalThis.Number(object.line) : 0,
- column: isSet(object.column) ? globalThis.Number(object.column) : 0,
startPosition: isSet(object.startPosition) ? Position.fromJSON(object.startPosition) : undefined,
endPosition: isSet(object.endPosition) ? Position.fromJSON(object.endPosition) : undefined,
};
@@ -2434,12 +2403,6 @@ export const Advice: MessageFns<Advice> = {
if (message.content !== "") {
obj.content = message.content;
}
- if (message.line !== 0) {
- obj.line = Math.round(message.line);
- }
- if (message.column !== 0) {
- obj.column = Math.round(message.column);
- }
if (message.startPosition !== undefined) {
obj.startPosition = Position.toJSON(message.startPosition);
}
@@ -2458,8 +2421,6 @@ export const Advice: MessageFns<Advice> = {
message.code = object.code ?? 0;
message.title = object.title ?? "";
message.content = object.content ?? "";
- message.line = object.line ?? 0;
- message.column = object.column ?? 0;
message.startPosition = (object.startPosition !== undefined && object.startPosition !== null)
? Position.fromPartial(object.startPosition)
: undefined;
diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/ErrorView/AdviceItem.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/ErrorView/AdviceItem.vue
index a3d393d50f..5de39ab75b 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/ErrorView/AdviceItem.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/ErrorView/AdviceItem.vue
@@ -52,13 +52,13 @@ const title = computed(() => {
const position = computed(() => {
const { advice, executeParams } = props;
const [startLine, startColumn] = positionWithOffset(
- advice.startPosition?.line ?? advice.line,
- advice.startPosition?.column ?? advice.column,
+ advice.startPosition?.line ?? 0,
+ advice.startPosition?.column ?? Number.MAX_SAFE_INTEGER,
executeParams?.selection
);
const [endLine, endColumn] = positionWithOffset(
- advice.endPosition?.line ?? advice.line,
- advice.endPosition?.column ?? advice.column,
+ advice.endPosition?.line ?? 0,
+ advice.endPosition?.column ?? Number.MAX_SAFE_INTEGER,
executeParams?.selection
);
return {
diff --git a/frontend/src/views/sql-editor/EditorPanel/StandardPanel/SQLEditor.vue b/frontend/src/views/sql-editor/EditorPanel/StandardPanel/SQLEditor.vue
index 29b830e7a4..6f7fa7a8b1 100644
--- a/frontend/src/views/sql-editor/EditorPanel/StandardPanel/SQLEditor.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/StandardPanel/SQLEditor.vue
@@ -357,15 +357,15 @@ const updateAdvices = (
) => {
tab.editorState.advices = advices.map<AdviceOption>((advice) => {
const [startLine, startColumn] = positionWithOffset(
- advice.startPosition?.line ?? advice.line,
- advice.startPosition?.column ?? advice.column,
+ advice.startPosition?.line ?? 1,
+ advice.startPosition?.column ?? Number.MAX_SAFE_INTEGER,
params.selection
);
const [endLine, endColumn] = positionWithOffset(
- advice.endPosition?.line ?? advice.startPosition?.line ?? advice.line,
+ advice.endPosition?.line ?? advice.startPosition?.line ?? 1,
advice.endPosition?.column ??
advice.startPosition?.column ??
- advice.column,
+ Number.MAX_SAFE_INTEGER,
params.selection
);
const code = advice.code;
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 203ec298c6..3515684e9a 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -8460,9 +8460,7 @@ TYPE_PROJECT_REPOSITORY_PUSH represents Bytebase receiving a push event from the
| code | [int32](#int32) | | The advice code. |
| title | [string](#string) | | The advice title. |
| content | [string](#string) | | The advice content. |
-| line | [int32](#int32) | | The advice line number in the SQL statement. |
-| column | [int32](#int32) | | The advice column number in the SQL statement. |
-| start_position | [Position](#bytebase-v1-Position) | | To supersede `line` and `column` above. The start_position is inclusive and the end_position is exclusive. TODO: use range instead |
+| start_position | [Position](#bytebase-v1-Position) | | The start_position is inclusive and the end_position is exclusive. TODO: use range instead |
| end_position | [Position](#bytebase-v1-Position) | | |
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index dcb0f04262..6a3228a472 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -23487,26 +23487,11 @@ CosmosDB only. </p></td>
<td><p>The advice content. </p></td>
</tr>
- <tr>
- <td>line</td>
- <td><a href="#int32">int32</a></td>
- <td></td>
- <td><p>The advice line number in the SQL statement. </p></td>
- </tr>
-
- <tr>
- <td>column</td>
- <td><a href="#int32">int32</a></td>
- <td></td>
- <td><p>The advice column number in the SQL statement. </p></td>
- </tr>
-
<tr>
<td>start_position</td>
<td><a href="#bytebase.v1.Position">Position</a></td>
<td></td>
- <td><p>To supersede `line` and `column` above.
-The start_position is inclusive and the end_position is exclusive.
+ <td><p>The start_position is inclusive and the end_position is exclusive.
TODO: use range instead </p></td>
</tr>
diff --git a/proto/generated-go/v1/sql_service.pb.go b/proto/generated-go/v1/sql_service.pb.go
index 12db2a0278..5dc0a4c51f 100644
--- a/proto/generated-go/v1/sql_service.pb.go
+++ b/proto/generated-go/v1/sql_service.pb.go
@@ -1039,11 +1039,6 @@ type Advice struct {
Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"`
// The advice content.
Content string `protobuf:"bytes,4,opt,name=content,proto3" json:"content,omitempty"`
- // The advice line number in the SQL statement.
- Line int32 `protobuf:"varint,5,opt,name=line,proto3" json:"line,omitempty"`
- // The advice column number in the SQL statement.
- Column int32 `protobuf:"varint,6,opt,name=column,proto3" json:"column,omitempty"`
- // To supersede `line` and `column` above.
// The start_position is inclusive and the end_position is exclusive.
// TODO: use range instead
StartPosition *Position `protobuf:"bytes,8,opt,name=start_position,json=startPosition,proto3" json:"start_position,omitempty"`
@@ -1110,20 +1105,6 @@ func (x *Advice) GetContent() string {
return ""
}
-func (x *Advice) GetLine() int32 {
- if x != nil {
- return x.Line
- }
- return 0
-}
-
-func (x *Advice) GetColumn() int32 {
- if x != nil {
- return x.Column
- }
- return 0
-}
-
func (x *Advice) GetStartPosition() *Position {
if x != nil {
return x.StartPosition
@@ -2665,21 +2646,19 @@ const file_v1_sql_service_proto_rawDesc = "" +
"\x04zone\x18\x02 \x01(\tR\x04zone\x12\x16\n" +
"\x06offset\x18\x03 \x01(\x05R\x06offset\x12\x1a\n" +
"\baccuracy\x18\x04 \x01(\x05R\baccuracyB\x06\n" +
- "\x04kind\"\xf1\x02\n" +
+ "\x04kind\"\xd1\x02\n" +
"\x06Advice\x122\n" +
"\x06status\x18\x01 \x01(\x0e2\x1a.bytebase.v1.Advice.StatusR\x06status\x12\x12\n" +
"\x04code\x18\x02 \x01(\x05R\x04code\x12\x14\n" +
"\x05title\x18\x03 \x01(\tR\x05title\x12\x18\n" +
- "\acontent\x18\x04 \x01(\tR\acontent\x12\x12\n" +
- "\x04line\x18\x05 \x01(\x05R\x04line\x12\x16\n" +
- "\x06column\x18\x06 \x01(\x05R\x06column\x12<\n" +
+ "\acontent\x18\x04 \x01(\tR\acontent\x12<\n" +
"\x0estart_position\x18\b \x01(\v2\x15.bytebase.v1.PositionR\rstartPosition\x128\n" +
"\fend_position\x18\t \x01(\v2\x15.bytebase.v1.PositionR\vendPosition\"E\n" +
"\x06Status\x12\x16\n" +
"\x12STATUS_UNSPECIFIED\x10\x00\x12\v\n" +
"\aSUCCESS\x10\x01\x12\v\n" +
"\aWARNING\x10\x02\x12\t\n" +
- "\x05ERROR\x10\x03J\x04\b\a\x10\b\"\x88\x02\n" +
+ "\x05ERROR\x10\x03J\x04\b\a\x10\bJ\x04\b\x05\x10\x06J\x04\b\x06\x10\a\"\x88\x02\n" +
"\rExportRequest\x122\n" +
"\x04name\x18\x01 \x01(\tB\x1e\xe2A\x01\x02\xfaA\x17\n" +
"\x15bytebase.com/DatabaseR\x04name\x12\x1c\n" +
diff --git a/proto/v1/sql_service.proto b/proto/v1/sql_service.proto
index de602bd9d3..cda63ac33e 100644
--- a/proto/v1/sql_service.proto
+++ b/proto/v1/sql_service.proto
@@ -323,13 +323,8 @@ message Advice {
// The advice content.
string content = 4;
- // The advice line number in the SQL statement.
- int32 line = 5;
+ reserved 5, 6;
- // The advice column number in the SQL statement.
- int32 column = 6;
-
- // To supersede `line` and `column` above.
// The start_position is inclusive and the end_position is exclusive.
// TODO: use range instead
Position start_position = 8;