Skip to content

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

fix: ghost test (#5397)

Danny Xub1588770dff8
diff --git a/backend/api/auth/auth.go b/backend/api/auth/auth.go
index e767b30194..4613e663c6 100644
--- a/backend/api/auth/auth.go
+++ b/backend/api/auth/auth.go
@@ -80,7 +80,7 @@ func New(store *store.Store, secret string, licenseService enterpriseAPI.License
}
// AuthenticationInterceptor is the unary interceptor for gRPC API.
-func (in *APIAuthInterceptor) AuthenticationInterceptor(ctx context.Context, request interface{}, serverInfo *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
+func (in *APIAuthInterceptor) AuthenticationInterceptor(ctx context.Context, request any, serverInfo *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
return nil, status.Errorf(codes.Unauthenticated, "failed to parse metadata from incoming context")
@@ -109,7 +109,7 @@ func (in *APIAuthInterceptor) authenticate(ctx context.Context, accessTokenStr,
}
claims := &claimsMessage{}
generateToken := false
- accessToken, err := jwt.ParseWithClaims(accessTokenStr, claims, func(t *jwt.Token) (interface{}, error) {
+ accessToken, err := jwt.ParseWithClaims(accessTokenStr, claims, func(t *jwt.Token) (any, error) {
if t.Method.Alg() != jwt.SigningMethodHS256.Name {
return nil, status.Errorf(codes.Unauthenticated, "unexpected access token signing method=%v, expect %v", t.Header["alg"], jwt.SigningMethodHS256)
}
@@ -163,7 +163,7 @@ func (in *APIAuthInterceptor) authenticate(ctx context.Context, accessTokenStr,
generateTokenFunc := func() error {
// Parses token and checks if it's valid.
refreshTokenClaims := &claimsMessage{}
- refreshToken, err := jwt.ParseWithClaims(refreshTokenStr, refreshTokenClaims, func(t *jwt.Token) (interface{}, error) {
+ refreshToken, err := jwt.ParseWithClaims(refreshTokenStr, refreshTokenClaims, func(t *jwt.Token) (any, error) {
if t.Method.Alg() != jwt.SigningMethodHS256.Name {
return nil, status.Errorf(codes.Unauthenticated, "unexpected refresh token signing method=%v, expected %v", t.Header["alg"], jwt.SigningMethodHS256)
}
@@ -211,7 +211,7 @@ func (in *APIAuthInterceptor) authenticate(ctx context.Context, accessTokenStr,
// GetUserIDFromMFATempToken returns the user ID from the MFA temp token.
func GetUserIDFromMFATempToken(token string, mode common.ReleaseMode, secret string) (int, error) {
claims := &claimsMessage{}
- _, err := jwt.ParseWithClaims(token, claims, func(t *jwt.Token) (interface{}, error) {
+ _, err := jwt.ParseWithClaims(token, claims, func(t *jwt.Token) (any, error) {
if t.Method.Alg() != jwt.SigningMethodHS256.Name {
return nil, status.Errorf(codes.Unauthenticated, "unexpected MFA temp token signing method=%v, expect %v", t.Header["alg"], jwt.SigningMethodHS256)
}
diff --git a/backend/api/v1/acl.go b/backend/api/v1/acl.go
index 95b93545e2..ad29fb717b 100644
--- a/backend/api/v1/acl.go
+++ b/backend/api/v1/acl.go
@@ -37,7 +37,7 @@ func NewACLInterceptor(store *store.Store, secret string, licenseService enterpr
}
// ACLInterceptor is the unary interceptor for gRPC API.
-func (in *ACLInterceptor) ACLInterceptor(ctx context.Context, request interface{}, serverInfo *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
+func (in *ACLInterceptor) ACLInterceptor(ctx context.Context, request any, serverInfo *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
user, err := in.getUser(ctx)
if err != nil {
return nil, status.Errorf(codes.PermissionDenied, err.Error())
@@ -133,7 +133,7 @@ func (in *ACLInterceptor) getProjectMember(ctx context.Context, user *store.User
return api.UnknownRole, nil
}
-func getProjectIDs(req interface{}) ([]string, error) {
+func getProjectIDs(req any) ([]string, error) {
if request, ok := req.(*v1pb.UpdateProjectRequest); ok {
if request.Project == nil {
return nil, errors.Errorf("project not found")
@@ -162,7 +162,7 @@ func getProjectIDs(req interface{}) ([]string, error) {
return nil, nil
}
-func (in *ACLInterceptor) getTransferDatabaseToProjects(ctx context.Context, req interface{}) ([]string, error) {
+func (in *ACLInterceptor) getTransferDatabaseToProjects(ctx context.Context, req any) ([]string, error) {
var requests []*v1pb.UpdateDatabaseRequest
if request, ok := req.(*v1pb.UpdateDatabaseRequest); ok {
requests = append(requests, request)
diff --git a/backend/api/v1/auth_service.go b/backend/api/v1/auth_service.go
index 9c140d9359..06e8f42f4b 100644
--- a/backend/api/v1/auth_service.go
+++ b/backend/api/v1/auth_service.go
@@ -166,7 +166,7 @@ func (s *AuthService) CreateUser(ctx context.Context, request *v1pb.CreateUserRe
s.metricReporter.Report(&metric.Metric{
Name: metricAPI.PrincipalRegistrationMetricName,
Value: 1,
- Labels: map[string]interface{}{
+ Labels: map[string]any{
"email": user.Email,
"name": user.Name,
// We only send lark notification for the first principal registration.
diff --git a/backend/api/v1/subscription_service.go b/backend/api/v1/subscription_service.go
index 416826b532..e94222891c 100644
--- a/backend/api/v1/subscription_service.go
+++ b/backend/api/v1/subscription_service.go
@@ -163,7 +163,7 @@ func (s *SubscriptionService) TrialSubscription(ctx context.Context, request *v1
s.metricReporter.Report(&metric.Metric{
Name: metricAPI.SubscriptionTrialMetricName,
Value: 1,
- Labels: map[string]interface{}{
+ Labels: map[string]any{
"trial_plan": currentPlan.String(),
"from_plan": basePlan.String(),
"lark_notified": false,
diff --git a/backend/common/error.go b/backend/common/error.go
index 6c0914546f..b41da90bfb 100644
--- a/backend/common/error.go
+++ b/backend/common/error.go
@@ -100,7 +100,7 @@ func ErrorMessage(err error) string {
}
// Wrapf is a helper function to wrap an Error with given code and formatted message.
-func Wrapf(err error, code Code, format string, args ...interface{}) *Error {
+func Wrapf(err error, code Code, format string, args ...any) *Error {
return &Error{
Code: code,
Err: pkgerrors.Wrapf(err, format, args...),
@@ -108,7 +108,7 @@ func Wrapf(err error, code Code, format string, args ...interface{}) *Error {
}
// Errorf is a helper function to create an Error with given code and formatted message.
-func Errorf(code Code, format string, args ...interface{}) *Error {
+func Errorf(code Code, format string, args ...any) *Error {
return &Error{
Code: code,
Err: pkgerrors.Errorf(format, args...),
diff --git a/backend/enterprise/config/keys/README.md b/backend/enterprise/config/keys/README.md
index 86fee12349..898cdcdb67 100644
--- a/backend/enterprise/config/keys/README.md
+++ b/backend/enterprise/config/keys/README.md
@@ -27,7 +27,7 @@ The `enterprise/config/config.go` will load keys depends on environment.
In `enterprise/service/license.go`, we will use public key to parse JWT
```go
-token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) {
+token, err := jwt.Parse(tokenString, func(token *jwt.Token) (any, error) {
if _, ok := token.Method.(*jwt.SigningMethodRSA); !ok {
return nil, errors.Errorf("unexpected signing method: %v", token.Header["alg"])
}
diff --git a/backend/enterprise/service/utils.go b/backend/enterprise/service/utils.go
index f34370c109..d6d93b81a8 100644
--- a/backend/enterprise/service/utils.go
+++ b/backend/enterprise/service/utils.go
@@ -7,7 +7,7 @@ import (
)
func parseJWTToken(tokenString, expectVersion, publicKey string, claims jwt.Claims) error {
- token, err := jwt.ParseWithClaims(tokenString, claims, func(token *jwt.Token) (interface{}, error) {
+ token, err := jwt.ParseWithClaims(tokenString, claims, func(token *jwt.Token) (any, error) {
if _, ok := token.Method.(*jwt.SigningMethodRSA); !ok {
return nil, common.Errorf(common.Invalid, "unexpected signing method: %v", token.Header["alg"])
}
diff --git a/backend/legacyapi/data_source.go b/backend/legacyapi/data_source.go
index 0864c481ea..be066b6310 100644
--- a/backend/legacyapi/data_source.go
+++ b/backend/legacyapi/data_source.go
@@ -52,7 +52,7 @@ func getDefaultDataSourceOptions() DataSourceOptions {
}
// Scan implements database/sql Scanner interface, converts JSONB to DataSourceOptions struct.
-func (d *DataSourceOptions) Scan(src interface{}) error {
+func (d *DataSourceOptions) Scan(src any) error {
if bs, ok := src.([]byte); ok {
if string(bs) == "{}" {
// handle '{}', return default values
diff --git a/backend/legacyapi/project_setting.go b/backend/legacyapi/project_setting.go
index 28bde697c3..cc775d0d19 100644
--- a/backend/legacyapi/project_setting.go
+++ b/backend/legacyapi/project_setting.go
@@ -30,7 +30,7 @@ func GetDefaultLGTMCheckSetting() LGTMCheckSetting {
}
// Scan implements database/sql Scanner interface, converts JSONB to LGTMCheckSetting struct.
-func (s *LGTMCheckSetting) Scan(src interface{}) error {
+func (s *LGTMCheckSetting) Scan(src any) error {
if bs, ok := src.([]byte); ok {
if string(bs) == "{}" {
// handle '{}', return default values
diff --git a/backend/metric/collector/database_count.go b/backend/metric/collector/database_count.go
index 5b39004271..a592c93c0d 100644
--- a/backend/metric/collector/database_count.go
+++ b/backend/metric/collector/database_count.go
@@ -33,7 +33,7 @@ func (c *databaseCountCollector) Collect(ctx context.Context) ([]*metric.Metric,
}
for _, databaseCountMetric := range databaseCountMetricList {
- labels := map[string]interface{}{
+ labels := map[string]any{
"backup_schedule": "null",
"backup_enabled": "null",
}
diff --git a/backend/metric/collector/instance_count.go b/backend/metric/collector/instance_count.go
index 0c3f2df33b..c02ccaffa7 100644
--- a/backend/metric/collector/instance_count.go
+++ b/backend/metric/collector/instance_count.go
@@ -44,7 +44,7 @@ func (c *instanceCountCollector) Collect(ctx context.Context) ([]*metric.Metric,
res = append(res, &metric.Metric{
Name: metricAPI.InstanceCountMetricName,
Value: instanceCountMetric.Count,
- Labels: map[string]interface{}{
+ Labels: map[string]any{
"engine": string(instanceCountMetric.Engine),
"environment": env.Name,
"status": string(instanceCountMetric.RowStatus),
diff --git a/backend/metric/collector/issue_count.go b/backend/metric/collector/issue_count.go
index 29f30d6822..bf1add6e5f 100644
--- a/backend/metric/collector/issue_count.go
+++ b/backend/metric/collector/issue_count.go
@@ -35,7 +35,7 @@ func (c *issueCountCollector) Collect(ctx context.Context) ([]*metric.Metric, er
res = append(res, &metric.Metric{
Name: metricAPI.IssueCountMetricName,
Value: issueCountMetric.Count,
- Labels: map[string]interface{}{
+ Labels: map[string]any{
"type": string(issueCountMetric.Type),
"status": string(issueCountMetric.Status),
},
diff --git a/backend/metric/collector/member_count.go b/backend/metric/collector/member_count.go
index 3f4e222dd0..e293a7293e 100644
--- a/backend/metric/collector/member_count.go
+++ b/backend/metric/collector/member_count.go
@@ -35,7 +35,7 @@ func (c *memberCountCollector) Collect(ctx context.Context) ([]*metric.Metric, e
res = append(res, &metric.Metric{
Name: metricAPI.MemberCountMetricName,
Value: memberCountMetric.Count,
- Labels: map[string]interface{}{
+ Labels: map[string]any{
"role": string(memberCountMetric.Role),
"status": string(memberCountMetric.Status),
"row_status": string(memberCountMetric.RowStatus),
diff --git a/backend/metric/collector/policy_count.go b/backend/metric/collector/policy_count.go
index 1ed7ff4378..9fb261cdbc 100644
--- a/backend/metric/collector/policy_count.go
+++ b/backend/metric/collector/policy_count.go
@@ -89,7 +89,7 @@ func (c *policyCountCollector) Collect(ctx context.Context) ([]*metric.Metric, e
res = append(res, &metric.Metric{
Name: metricAPI.PolicyCountMetricName,
Value: policyCountMetric.Count,
- Labels: map[string]interface{}{
+ Labels: map[string]any{
"type": string(policyCountMetric.Type),
"environment": policyCountMetric.EnvironmentName,
"value": policyCountMetric.Value,
diff --git a/backend/metric/collector/project_count.go b/backend/metric/collector/project_count.go
index aaf8f71160..3cd8562fd4 100644
--- a/backend/metric/collector/project_count.go
+++ b/backend/metric/collector/project_count.go
@@ -35,7 +35,7 @@ func (c *projectCountCollector) Collect(ctx context.Context) ([]*metric.Metric,
res = append(res, &metric.Metric{
Name: metricAPI.ProjectCountMetricName,
Value: projectCountMetric.Count,
- Labels: map[string]interface{}{
+ Labels: map[string]any{
"tenant_mode": string(projectCountMetric.TenantMode),
"workflow": string(projectCountMetric.WorkflowType),
"status": string(projectCountMetric.RowStatus),
diff --git a/backend/metric/collector/sheet_count.go b/backend/metric/collector/sheet_count.go
index fd1260dacb..9f9fa62417 100644
--- a/backend/metric/collector/sheet_count.go
+++ b/backend/metric/collector/sheet_count.go
@@ -35,7 +35,7 @@ func (c *sheetCountCollector) Collect(ctx context.Context) ([]*metric.Metric, er
res = append(res, &metric.Metric{
Name: metricAPI.SheetCountMetricName,
Value: sheetCountMetric.Count,
- Labels: map[string]interface{}{
+ Labels: map[string]any{
"row_status": string(sheetCountMetric.RowStatus),
"visibility": string(sheetCountMetric.Visibility),
"source": string(sheetCountMetric.Source),
diff --git a/backend/metric/collector/task_count.go b/backend/metric/collector/task_count.go
index 66cc4f2000..f1b163bb14 100644
--- a/backend/metric/collector/task_count.go
+++ b/backend/metric/collector/task_count.go
@@ -35,7 +35,7 @@ func (c *taskCountCollector) Collect(ctx context.Context) ([]*metric.Metric, err
res = append(res, &metric.Metric{
Name: metricAPI.TaskCountMetricName,
Value: taskCountMetric.Count,
- Labels: map[string]interface{}{
+ Labels: map[string]any{
"type": string(taskCountMetric.Type),
"status": string(taskCountMetric.Status),
},
diff --git a/backend/plugin/advisor/catalog/walk_through.go b/backend/plugin/advisor/catalog/walk_through.go
index 5de40256cf..e66baa6ed8 100644
--- a/backend/plugin/advisor/catalog/walk_through.go
+++ b/backend/plugin/advisor/catalog/walk_through.go
@@ -130,7 +130,7 @@ type WalkThroughError struct {
Content string
Line int
- Payload interface{}
+ Payload any
}
// NewParseError returns a new ErrorTypeParseError.
diff --git a/backend/plugin/advisor/catalog/walk_through_test.go b/backend/plugin/advisor/catalog/walk_through_test.go
index 6eebd2aab8..4034a5c2d4 100644
--- a/backend/plugin/advisor/catalog/walk_through_test.go
+++ b/backend/plugin/advisor/catalog/walk_through_test.go
@@ -105,7 +105,7 @@ func TestPostgreSQLWalkThrough(t *testing.T) {
}
}
-func convertInterfaceSliceToStringSlice(slice []interface{}) []string {
+func convertInterfaceSliceToStringSlice(slice []any) []string {
var res []string
for _, item := range slice {
res = append(res, item.(string))
@@ -146,7 +146,7 @@ func runWalkThroughTest(t *testing.T, file string, engineType db.Type, originDat
if err.Payload != nil {
actualPayloadText, yes := err.Payload.([]string)
require.True(t, yes)
- expectedPayloadText := convertInterfaceSliceToStringSlice(test.Err.Payload.([]interface{}))
+ expectedPayloadText := convertInterfaceSliceToStringSlice(test.Err.Payload.([]any))
err.Payload = nil
test.Err.Payload = nil
require.Equal(t, test.Err, err)
diff --git a/backend/plugin/advisor/config.go b/backend/plugin/advisor/config.go
index aa0c1f545d..dde4bda4fb 100644
--- a/backend/plugin/advisor/config.go
+++ b/backend/plugin/advisor/config.go
@@ -28,10 +28,10 @@ type SQLReviewTemplateData struct {
// SQLReviewRuleData is the API message for SQL review rule update.
type SQLReviewRuleData struct {
- Type SQLReviewRuleType `yaml:"type"`
- Level SQLReviewRuleLevel `yaml:"level,omitempty"`
- Comment string `yaml:"comment"`
- Payload map[string]interface{} `yaml:"payload"`
+ Type SQLReviewRuleType `yaml:"type"`
+ Level SQLReviewRuleLevel `yaml:"level,omitempty"`
+ Comment string `yaml:"comment"`
+ Payload map[string]any `yaml:"payload"`
}
// SQLReviewConfigOverride is the API message for SQL review configuration override.
diff --git a/backend/plugin/advisor/mysql/advisor_insert_row_limit.go b/backend/plugin/advisor/mysql/advisor_insert_row_limit.go
index 3ebafe648d..192395274a 100644
--- a/backend/plugin/advisor/mysql/advisor_insert_row_limit.go
+++ b/backend/plugin/advisor/mysql/advisor_insert_row_limit.go
@@ -136,14 +136,14 @@ func (*insertRowLimitChecker) Leave(in ast.Node) (ast.Node, bool) {
return in, true
}
-func getInsertRows(res []interface{}) (int64, error) {
- // the res struct is []interface{}{columnName, columnTable, rowDataList}
+func getInsertRows(res []any) (int64, error) {
+ // the res struct is []any{columnName, columnTable, rowDataList}
if len(res) != 3 {
return 0, errors.Errorf("expected 3 but got %d", len(res))
}
- rowList, ok := res[2].([]interface{})
+ rowList, ok := res[2].([]any)
if !ok {
- return 0, errors.Errorf("expected []interface{} but got %t", res[2])
+ return 0, errors.Errorf("expected []any but got %t", res[2])
}
// mysql> explain insert into td select * from td;
// +----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+-----------------+
@@ -156,9 +156,9 @@ func getInsertRows(res []interface{}) (int64, error) {
return 0, errors.Errorf("not found any data")
}
// We need the row 2.
- rowTwo, ok := rowList[1].([]interface{})
+ rowTwo, ok := rowList[1].([]any)
if !ok {
- return 0, errors.Errorf("expected []interface{} but got %t", rowList[0])
+ return 0, errors.Errorf("expected []any but got %t", rowList[0])
}
// MySQL EXPLAIN statement result has 12 columns.
if len(rowTwo) != 12 {
diff --git a/backend/plugin/advisor/mysql/advisor_statement_affected_row_limit.go b/backend/plugin/advisor/mysql/advisor_statement_affected_row_limit.go
index 71da9f7d7e..34ca158dd9 100644
--- a/backend/plugin/advisor/mysql/advisor_statement_affected_row_limit.go
+++ b/backend/plugin/advisor/mysql/advisor_statement_affected_row_limit.go
@@ -125,21 +125,21 @@ func (*statementAffectedRowLimitChecker) Leave(in ast.Node) (ast.Node, bool) {
return in, true
}
-func getRows(res []interface{}) (int64, error) {
- // the res struct is []interface{}{columnName, columnTable, rowDataList}
+func getRows(res []any) (int64, error) {
+ // the res struct is []any{columnName, columnTable, rowDataList}
if len(res) != 3 {
return 0, errors.Errorf("expected 3 but got %d", len(res))
}
- rowList, ok := res[2].([]interface{})
+ rowList, ok := res[2].([]any)
if !ok {
- return 0, errors.Errorf("expected []interface{} but got %t", res[2])
+ return 0, errors.Errorf("expected []any but got %t", res[2])
}
if len(rowList) < 1 {
return 0, errors.Errorf("not found any data")
}
- rowOne, ok := rowList[0].([]interface{})
+ rowOne, ok := rowList[0].([]any)
if !ok {
- return 0, errors.Errorf("expected []interface{} but got %t", rowList[0])
+ return 0, errors.Errorf("expected []any but got %t", rowList[0])
}
// MySQL EXPLAIN statement result has 12 columns.
//
diff --git a/backend/plugin/advisor/pg/advisor_insert_row_limit.go b/backend/plugin/advisor/pg/advisor_insert_row_limit.go
index cb460381ad..d804d9d725 100644
--- a/backend/plugin/advisor/pg/advisor_insert_row_limit.go
+++ b/backend/plugin/advisor/pg/advisor_insert_row_limit.go
@@ -134,14 +134,14 @@ func (checker *insertRowLimitChecker) Visit(node ast.Node) ast.Visitor {
return checker
}
-func getAffectedRows(res []interface{}) (int64, error) {
- // the res struct is []interface{}{columnName, columnTable, rowDataList}
+func getAffectedRows(res []any) (int64, error) {
+ // the res struct is []any{columnName, columnTable, rowDataList}
if len(res) != 3 {
return 0, errors.Errorf("expected 3 but got %d", len(res))
}
- rowList, ok := res[2].([]interface{})
+ rowList, ok := res[2].([]any)
if !ok {
- return 0, errors.Errorf("expected []interface{} but got %t", res[2])
+ return 0, errors.Errorf("expected []any but got %t", res[2])
}
// test-bb=# EXPLAIN INSERT INTO t SELECT * FROM t;
// QUERY PLAN
@@ -153,9 +153,9 @@ func getAffectedRows(res []interface{}) (int64, error) {
return 0, errors.Errorf("not found any data")
}
// We need the row 2.
- rowTwo, ok := rowList[1].([]interface{})
+ rowTwo, ok := rowList[1].([]any)
if !ok {
- return 0, errors.Errorf("expected []interface{} but got %t", rowList[0])
+ return 0, errors.Errorf("expected []any but got %t", rowList[0])
}
// PostgreSQL EXPLAIN statement result has one column.
if len(rowTwo) != 1 {
diff --git a/backend/plugin/advisor/utils.go b/backend/plugin/advisor/utils.go
index 67c3520940..406bb482e1 100644
--- a/backend/plugin/advisor/utils.go
+++ b/backend/plugin/advisor/utils.go
@@ -16,7 +16,7 @@ func NormalizeStatement(statement string) string {
}
// Query runs the EXPLAIN or SELECT statements for advisors.
-func Query(ctx context.Context, connection *sql.DB, statement string) ([]interface{}, error) {
+func Query(ctx context.Context, connection *sql.DB, statement string) ([]any, error) {
tx, err := connection.BeginTx(ctx, &sql.TxOptions{})
if err != nil {
return nil, err
@@ -48,9 +48,9 @@ func Query(ctx context.Context, connection *sql.DB, statement string) ([]interfa
columnTypeNames = append(columnTypeNames, strings.ToUpper(v.DatabaseTypeName()))
}
- data := []interface{}{}
+ data := []any{}
for rows.Next() {
- scanArgs := make([]interface{}, colCount)
+ scanArgs := make([]any, colCount)
for i, v := range columnTypeNames {
// TODO(steven need help): Consult a common list of data types from database driver documentation. e.g. MySQL,PostgreSQL.
switch v {
@@ -71,7 +71,7 @@ func Query(ctx context.Context, connection *sql.DB, statement string) ([]interfa
return nil, err
}
- rowData := []interface{}{}
+ rowData := []any{}
for i := range columnTypes {
if v, ok := (scanArgs[i]).(*sql.NullBool); ok && v.Valid {
rowData = append(rowData, v.Bool)
@@ -103,5 +103,5 @@ func Query(ctx context.Context, connection *sql.DB, statement string) ([]interfa
return nil, err
}
- return []interface{}{columnNames, columnTypeNames, data}, nil
+ return []any{columnNames, columnTypeNames, data}, nil
}
diff --git a/backend/plugin/advisor/utils_for_tests.go b/backend/plugin/advisor/utils_for_tests.go
index 3cc992e2f6..eff276b035 100644
--- a/backend/plugin/advisor/utils_for_tests.go
+++ b/backend/plugin/advisor/utils_for_tests.go
@@ -248,36 +248,36 @@ func (*MockDriver) Execute(_ context.Context, _ string, _ bool) (int64, error) {
}
// QueryConn implements the Driver interface.
-func (*MockDriver) QueryConn(_ context.Context, _ *sql.Conn, statement string, _ *database.QueryContext) ([]interface{}, error) {
+func (*MockDriver) QueryConn(_ context.Context, _ *sql.Conn, statement string, _ *database.QueryContext) ([]any, error) {
switch statement {
// For TestStatementDMLDryRun
case "EXPLAIN DELETE FROM tech_book":
return nil, errors.Errorf("MockDriver disallows it")
// For TestStatementAffectedRowLimit
case "EXPLAIN UPDATE tech_book SET id = 1":
- return []interface{}{
+ return []any{
nil,
nil,
- []interface{}{
- []interface{}{nil, nil, nil, nil, nil, nil, nil, nil, nil, 1000, nil, nil},
+ []any{
+ []any{nil, nil, nil, nil, nil, nil, nil, nil, nil, 1000, nil, nil},
},
}, nil
// For TestInsertRowLimit
case "EXPLAIN INSERT INTO tech_book SELECT * FROM tech_book":
- return []interface{}{
+ return []any{
nil,
nil,
- []interface{}{
+ []any{
nil,
- []interface{}{nil, nil, nil, nil, nil, nil, nil, nil, nil, 1000, nil, nil},
+ []any{nil, nil, nil, nil, nil, nil, nil, nil, nil, 1000, nil, nil},
},
}, nil
}
- return []interface{}{
+ return []any{
nil,
nil,
- []interface{}{
- []interface{}{nil, nil, nil, nil, nil, nil, nil, nil, nil, 1, nil, nil},
+ []any{
+ []any{nil, nil, nil, nil, nil, nil, nil, nil, nil, 1, nil, nil},
},
}, nil
}
diff --git a/backend/plugin/db/clickhouse/clickhouse.go b/backend/plugin/db/clickhouse/clickhouse.go
index 5f8252155f..c0cbe3e536 100644
--- a/backend/plugin/db/clickhouse/clickhouse.go
+++ b/backend/plugin/db/clickhouse/clickhouse.go
@@ -156,6 +156,6 @@ func (driver *Driver) Execute(ctx context.Context, statement string, _ bool) (in
}
// QueryConn querys a SQL statement in a given connection.
-func (driver *Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext *db.QueryContext) ([]interface{}, error) {
+func (driver *Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext *db.QueryContext) ([]any, error) {
return util.Query(ctx, driver.dbType, conn, statement, queryContext)
}
diff --git a/backend/plugin/db/clickhouse/migrate.go b/backend/plugin/db/clickhouse/migrate.go
index 69653b67ad..03c8b0af31 100644
--- a/backend/plugin/db/clickhouse/migrate.go
+++ b/backend/plugin/db/clickhouse/migrate.go
@@ -245,7 +245,7 @@ func (driver *Driver) FindMigrationHistoryList(ctx context.Context, find *db.Mig
issue_id,
payload
FROM bytebase.migration_history `
- paramNames, params := []string{}, []interface{}{}
+ paramNames, params := []string{}, []any{}
if v := find.ID; v != nil {
paramNames, params = append(paramNames, "id"), append(params, *v)
}
diff --git a/backend/plugin/db/driver.go b/backend/plugin/db/driver.go
index fecad233e7..54ee0faa71 100644
--- a/backend/plugin/db/driver.go
+++ b/backend/plugin/db/driver.go
@@ -460,7 +460,7 @@ type Driver interface {
// will not use transactions to execute the statement but will still use transactions to execute the rest of statements.
Execute(ctx context.Context, statement string, createDatabase bool) (int64, error)
// Used for execute readonly SELECT statement
- QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext *QueryContext) ([]interface{}, error)
+ QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext *QueryContext) ([]any, error)
// Sync schema
// SyncInstance syncs the instance metadata.
diff --git a/backend/plugin/db/mongodb/migrate.go b/backend/plugin/db/mongodb/migrate.go
index 74a697555f..993e98c80a 100644
--- a/backend/plugin/db/mongodb/migrate.go
+++ b/backend/plugin/db/mongodb/migrate.go
@@ -93,11 +93,11 @@ func (driver *Driver) SetupMigrationIfNeeded(ctx context.Context) error {
return errors.Wrapf(err, "failed to create collection %q in mongodb database %q for instance named %q", migrationHistoryDefaultCollection, migrationHistoryDefaultDatabase, driver.connectionCtx.InstanceID)
}
- var b interface{}
+ var b any
if err := bson.UnmarshalExtJSON([]byte(collmodMigrationHistoryCollectionCommand), true, &b); err != nil {
return errors.Wrap(err, "failed to unmarshal collmod command")
}
- var result interface{}
+ var result any
if err := database.RunCommand(context.Background(), b).Decode(&result); err != nil {
return errors.Wrap(err, "failed to run collmod command")
}
diff --git a/backend/plugin/db/mongodb/mongodb.go b/backend/plugin/db/mongodb/mongodb.go
index cb9127d0dc..4ed13d3023 100644
--- a/backend/plugin/db/mongodb/mongodb.go
+++ b/backend/plugin/db/mongodb/mongodb.go
@@ -125,7 +125,7 @@ func (driver *Driver) Execute(_ context.Context, statement string, _ bool) (int6
}
// QueryConn querys statements and returns the result.
-func (driver *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement string, _ *db.QueryContext) ([]interface{}, error) {
+func (driver *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement string, _ *db.QueryContext) ([]any, error) {
connectionURI := getMongoDBConnectionURI(driver.connCfg)
// For MongoDB query, we execute the statement in mongosh with flag --eval for the following reasons:
// 1. Query always short, so it's safe to execute in the command line.
@@ -148,8 +148,8 @@ func (driver *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement stri
}
field := []string{"result"}
types := []string{"TEXT"}
- rows := [][]interface{}{{outContent.String()}}
- return []interface{}{field, types, rows}, nil
+ rows := [][]any{{outContent.String()}}
+ return []any{field, types, rows}, nil
}
// Dump dumps the database.
diff --git a/backend/plugin/db/mongodb/sync.go b/backend/plugin/db/mongodb/sync.go
index c9f45bf75a..eaa93ef0c5 100644
--- a/backend/plugin/db/mongodb/sync.go
+++ b/backend/plugin/db/mongodb/sync.go
@@ -272,7 +272,7 @@ func isAtlasUnauthorizedError(err error) bool {
return strings.Contains(err.Error(), "AtlasError: Unauthorized")
}
-func convertEmptyInterfaceToInt64(value interface{}) (int64, error) {
+func convertEmptyInterfaceToInt64(value any) (int64, error) {
// NOTE: convert uint64 to int64 may cause overflow. But we don't care about it.
switch v := value.(type) {
case int:
diff --git a/backend/plugin/db/mssql/mssql.go b/backend/plugin/db/mssql/mssql.go
index 76c87423d6..70a2583f4b 100644
--- a/backend/plugin/db/mssql/mssql.go
+++ b/backend/plugin/db/mssql/mssql.go
@@ -122,6 +122,6 @@ func (driver *Driver) Execute(ctx context.Context, statement string, createDatab
}
// QueryConn querys a SQL statement in a given connection.
-func (*Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext *db.QueryContext) ([]interface{}, error) {
+func (*Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext *db.QueryContext) ([]any, error) {
return util.Query(ctx, db.MSSQL, conn, statement, queryContext)
}
diff --git a/backend/plugin/db/mysql/dump.go b/backend/plugin/db/mysql/dump.go
index b7fb8a07b9..4e29fd1d79 100644
--- a/backend/plugin/db/mysql/dump.go
+++ b/backend/plugin/db/mysql/dump.go
@@ -360,7 +360,7 @@ func excludeSchemaAutoIncrementValue(s string) string {
func GetBinlogInfo(ctx context.Context, db *sql.DB) (api.BinlogInfo, error) {
query := "SHOW MASTER STATUS"
binlogInfo := api.BinlogInfo{}
- var unused interface{}
+ var unused any
rows, err := db.QueryContext(ctx, query)
if err != nil {
return api.BinlogInfo{}, errors.Wrapf(err, "cannot execute %q query", query)
@@ -391,7 +391,7 @@ func GetBinlogInfo(ctx context.Context, db *sql.DB) (api.BinlogInfo, error) {
if scanOneRow {
return api.BinlogInfo{}, errors.Errorf("unexpected multiple rows returned from %q query", query)
}
- cols := make([]interface{}, len(columns))
+ cols := make([]any, len(columns))
scanOneRow = true
// The query SHOW MASTER STATUS returns uncertain number of columns, especially for the RDS, which may returns 4 columns.
// So we have to dynamically scan the columns, and return the error if we cannot find the File and Position columns.
@@ -575,7 +575,7 @@ func exportTableData(txn *sql.Tx, dbName, tblName string, includeDbPrefix bool,
return nil
}
values := make([]*sql.NullString, len(cols))
- refs := make([]interface{}, len(cols))
+ refs := make([]any, len(cols))
for i := 0; i < len(cols); i++ {
refs[i] = &values[i]
}
@@ -634,17 +634,17 @@ func getRoutines(txn *sql.Tx, dbName string) ([]*routineSchema, error) {
if err != nil {
return err
}
- var values []interface{}
+ var values []any
for i := 0; i < len(cols); i++ {
- values = append(values, new(interface{}))
+ values = append(values, new(any))
}
for rows.Next() {
var r routineSchema
if err := rows.Scan(values...); err != nil {
return err
}
- r.name = fmt.Sprintf("%s", *values[1].(*interface{}))
- r.routineType = fmt.Sprintf("%s", *values[2].(*interface{}))
+ r.name = fmt.Sprintf("%s", *values[1].(*any))
+ r.routineType = fmt.Sprintf("%s", *values[2].(*any))
routines = append(routines, &r)
}
@@ -710,16 +710,16 @@ func getEvents(txn *sql.Tx, dbName string) ([]*eventSchema, error) {
if err != nil {
return nil, err
}
- var values []interface{}
+ var values []any
for i := 0; i < len(cols); i++ {
- values = append(values, new(interface{}))
+ values = append(values, new(any))
}
for rows.Next() {
var r eventSchema
if err := rows.Scan(values...); err != nil {
return nil, err
}
- r.name = fmt.Sprintf("%s", *values[1].(*interface{}))
+ r.name = fmt.Sprintf("%s", *values[1].(*any))
events = append(events, &r)
}
if err := rows.Err(); err != nil {
@@ -763,16 +763,16 @@ func getTriggers(txn *sql.Tx, dbName string) ([]*triggerSchema, error) {
if err != nil {
return nil, err
}
- var values []interface{}
+ var values []any
for i := 0; i < len(cols); i++ {
- values = append(values, new(interface{}))
+ values = append(values, new(any))
}
for rows.Next() {
var tr triggerSchema
if err := rows.Scan(values...); err != nil {
return nil, err
}
- tr.name = fmt.Sprintf("%s", *values[0].(*interface{}))
+ tr.name = fmt.Sprintf("%s", *values[0].(*any))
triggers = append(triggers, &tr)
}
if err := rows.Err(); err != nil {
diff --git a/backend/plugin/db/mysql/migrate.go b/backend/plugin/db/mysql/migrate.go
index 0353044154..d03f4284b7 100644
--- a/backend/plugin/db/mysql/migrate.go
+++ b/backend/plugin/db/mysql/migrate.go
@@ -227,7 +227,7 @@ func (driver *Driver) FindMigrationHistoryList(ctx context.Context, find *db.Mig
issue_id,
payload
FROM bytebase.migration_history `
- paramNames, params := []string{}, []interface{}{}
+ paramNames, params := []string{}, []any{}
if v := find.ID; v != nil {
paramNames, params = append(paramNames, "id"), append(params, *v)
}
diff --git a/backend/plugin/db/mysql/mysql.go b/backend/plugin/db/mysql/mysql.go
index e70a982694..f05227a07a 100644
--- a/backend/plugin/db/mysql/mysql.go
+++ b/backend/plugin/db/mysql/mysql.go
@@ -216,7 +216,7 @@ func (driver *Driver) GetMigrationConnID(ctx context.Context) (string, error) {
}
// QueryConn querys a SQL statement in a given connection.
-func (driver *Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext *db.QueryContext) ([]interface{}, error) {
+func (driver *Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext *db.QueryContext) ([]any, error) {
singleSQLs, err := bbparser.SplitMultiSQL(bbparser.MySQL, statement)
if err != nil {
return nil, err
@@ -238,8 +238,8 @@ func (driver *Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement s
field := []string{"Affected Rows"}
types := []string{"INT"}
- rows := [][]interface{}{{affectedRows}}
- return []interface{}{field, types, rows}, nil
+ rows := [][]any{{affectedRows}}
+ return []any{field, types, rows}, nil
}
return util.Query(ctx, driver.dbType, conn, statement, queryContext)
}
diff --git a/backend/plugin/db/mysql/restore.go b/backend/plugin/db/mysql/restore.go
index c16cb7d451..6b7f5ba120 100644
--- a/backend/plugin/db/mysql/restore.go
+++ b/backend/plugin/db/mysql/restore.go
@@ -838,7 +838,7 @@ func (driver *Driver) GetSortedBinlogFilesOnServer(ctx context.Context) ([]Binlo
for rows.Next() {
var name string
var size int64
- var unused interface{}
+ var unused any
if err := rows.Scan(&name, &size, &unused /*Encrypted column*/); err != nil {
return nil, err
}
diff --git a/backend/plugin/db/oracle/oracle.go b/backend/plugin/db/oracle/oracle.go
index 55318d4b19..5c9f27e311 100644
--- a/backend/plugin/db/oracle/oracle.go
+++ b/backend/plugin/db/oracle/oracle.go
@@ -131,6 +131,6 @@ func (driver *Driver) executeWithBeforeCommitTxFunc(ctx context.Context, stateme
}
// QueryConn querys a SQL statement in a given connection.
-func (*Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext *db.QueryContext) ([]interface{}, error) {
+func (*Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext *db.QueryContext) ([]any, error) {
return util.Query(ctx, db.Oracle, conn, statement, queryContext)
}
diff --git a/backend/plugin/db/pg/migrate.go b/backend/plugin/db/pg/migrate.go
index 98ae2dd3ce..f49dd98d80 100644
--- a/backend/plugin/db/pg/migrate.go
+++ b/backend/plugin/db/pg/migrate.go
@@ -279,7 +279,7 @@ func (driver *Driver) FindMigrationHistoryList(ctx context.Context, find *db.Mig
issue_id,
payload
FROM migration_history `
- paramNames, params := []string{}, []interface{}{}
+ paramNames, params := []string{}, []any{}
if v := find.ID; v != nil {
paramNames, params = append(paramNames, "id"), append(params, *v)
}
diff --git a/backend/plugin/db/pg/pg.go b/backend/plugin/db/pg/pg.go
index 8c6413bafb..31ca4bd4c4 100644
--- a/backend/plugin/db/pg/pg.go
+++ b/backend/plugin/db/pg/pg.go
@@ -468,7 +468,7 @@ func (driver *Driver) GetCurrentDatabaseOwner() (string, error) {
}
// QueryConn querys a SQL statement in a given connection.
-func (*Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext *db.QueryContext) ([]interface{}, error) {
+func (*Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext *db.QueryContext) ([]any, error) {
singleSQLs, err := parser.SplitMultiSQL(parser.Postgres, statement)
if err != nil {
return nil, err
@@ -490,8 +490,8 @@ func (*Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string,
}
field := []string{"Affected Rows"}
types := []string{"INT"}
- rows := [][]interface{}{{affectedRows}}
- return []interface{}{field, types, rows}, nil
+ rows := [][]any{{affectedRows}}
+ return []any{field, types, rows}, nil
}
return util.Query(ctx, db.Postgres, conn, statement, queryContext)
}
diff --git a/backend/plugin/db/redis/redis.go b/backend/plugin/db/redis/redis.go
index b5205b879e..753949ffa6 100644
--- a/backend/plugin/db/redis/redis.go
+++ b/backend/plugin/db/redis/redis.go
@@ -124,7 +124,7 @@ func (d *Driver) Execute(ctx context.Context, statement string, createDatabase b
if line == "" {
continue
}
- var input []interface{}
+ var input []any
for _, s := range strings.Split(line, " ") {
input = append(input, s)
}
@@ -139,13 +139,13 @@ func (d *Driver) Execute(ctx context.Context, statement string, createDatabase b
}
// QueryConn executes the statement, returns the results.
-func (d *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement string, _ *db.QueryContext) ([]interface{}, error) {
+func (d *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement string, _ *db.QueryContext) ([]any, error) {
lines := strings.Split(statement, "\n")
for i := range lines {
lines[i] = strings.Trim(lines[i], " \n\t\r")
}
- var data []interface{}
+ var data []any
var cmds []*redis.Cmd
if _, err := d.rdb.Pipelined(ctx, func(p redis.Pipeliner) error {
@@ -153,7 +153,7 @@ func (d *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement string, _
if line == "" {
continue
}
- var input []interface{}
+ var input []any
for _, s := range strings.Split(line, " ") {
input = append(input, s)
}
@@ -167,20 +167,20 @@ func (d *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement string, _
for _, cmd := range cmds {
if cmd.Err() == redis.Nil {
- data = append(data, []interface{}{"redis: nil"})
+ data = append(data, []any{"redis: nil"})
continue
}
val := cmd.Val()
- if _, ok := val.(map[interface{}]interface{}); ok {
- // json.Marshal cannot handle map[interface{}]interface{}
+ if _, ok := val.(map[any]any); ok {
+ // json.Marshal cannot handle map[any]any
val = cmd.String()
}
- data = append(data, []interface{}{val})
+ data = append(data, []any{val})
}
- return []interface{}{[]string{"result"}, []string{"TEXT"}, data}, nil
+ return []any{[]string{"result"}, []string{"TEXT"}, data}, nil
}
// Dump and restore
diff --git a/backend/plugin/db/redshift/redshift.go b/backend/plugin/db/redshift/redshift.go
index 28a58284a4..c65891ec9d 100644
--- a/backend/plugin/db/redshift/redshift.go
+++ b/backend/plugin/db/redshift/redshift.go
@@ -405,7 +405,7 @@ func getDatabaseInCreateDatabaseStatement(createDatabaseStatement string) (strin
}
// QueryConn will query the database using the provided connection, it is useful for keeping the context of the connection.
-func (*Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext *db.QueryContext) ([]interface{}, error) {
+func (*Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext *db.QueryContext) ([]any, error) {
singleSQLs, err := parser.SplitMultiSQL(parser.Postgres, statement)
if err != nil {
return nil, err
@@ -427,8 +427,8 @@ func (*Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string,
}
field := []string{"Affected Rows"}
types := []string{"INT"}
- rows := [][]interface{}{{affectedRows}}
- return []interface{}{field, types, rows}, nil
+ rows := [][]any{{affectedRows}}
+ return []any{field, types, rows}, nil
}
return util.Query(ctx, db.Postgres, conn, statement, queryContext)
}
diff --git a/backend/plugin/db/snowflake/migrate.go b/backend/plugin/db/snowflake/migrate.go
index e4fddd935e..30230fcfed 100644
--- a/backend/plugin/db/snowflake/migrate.go
+++ b/backend/plugin/db/snowflake/migrate.go
@@ -252,7 +252,7 @@ func (driver *Driver) FindMigrationHistoryList(ctx context.Context, find *db.Mig
issue_id,
payload
FROM bytebase.public.migration_history `
- paramNames, params := []string{}, []interface{}{}
+ paramNames, params := []string{}, []any{}
if v := find.ID; v != nil {
paramNames, params = append(paramNames, "id"), append(params, *v)
}
diff --git a/backend/plugin/db/snowflake/snowflake.go b/backend/plugin/db/snowflake/snowflake.go
index 9a0383a2c7..ac3f854188 100644
--- a/backend/plugin/db/snowflake/snowflake.go
+++ b/backend/plugin/db/snowflake/snowflake.go
@@ -162,7 +162,7 @@ func getDatabasesTxn(ctx context.Context, tx *sql.Tx) ([]string, error) {
return nil, nil
}
values := make([]*sql.NullString, len(cols))
- refs := make([]interface{}, len(cols))
+ refs := make([]any, len(cols))
for i := 0; i < len(cols); i++ {
refs[i] = &values[i]
}
@@ -251,6 +251,6 @@ func (driver *Driver) Execute(ctx context.Context, statement string, _ bool) (in
}
// QueryConn querys a SQL statement in a given connection.
-func (*Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext *db.QueryContext) ([]interface{}, error) {
+func (*Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext *db.QueryContext) ([]any, error) {
return util.Query(ctx, db.Snowflake, conn, statement, queryContext)
}
diff --git a/backend/plugin/db/spanner/migrate.go b/backend/plugin/db/spanner/migrate.go
index 094156c90e..82b49b6ea4 100644
--- a/backend/plugin/db/spanner/migrate.go
+++ b/backend/plugin/db/spanner/migrate.go
@@ -120,7 +120,7 @@ func (d *Driver) FindMigrationHistoryList(ctx context.Context, find *db.Migratio
payload
FROM migration_history
`
- params := make(map[string]interface{})
+ params := make(map[string]any)
var where []string
if v := find.ID; v != nil {
diff --git a/backend/plugin/db/spanner/spanner.go b/backend/plugin/db/spanner/spanner.go
index e0082575e5..cca9c0c992 100644
--- a/backend/plugin/db/spanner/spanner.go
+++ b/backend/plugin/db/spanner/spanner.go
@@ -195,7 +195,7 @@ func (d *Driver) Execute(ctx context.Context, statement string, createDatabase b
}
// QueryConn querys statements.
-func (d *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement string, queryContext *db.QueryContext) ([]interface{}, error) {
+func (d *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement string, queryContext *db.QueryContext) ([]any, error) {
stmts, err := sanitizeSQL(statement)
if err != nil {
return nil, err
@@ -221,7 +221,7 @@ func (d *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement string, q
return nil, err
}
- data := []interface{}{}
+ data := []any{}
columnNames := getColumnNames(iter)
columnTypeNames, err := getColumnTypeNames(iter)
if err != nil {
@@ -247,10 +247,10 @@ func (d *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement string, q
// spanner doesn't mask the sensitive fields.
// Return the all false boolean slice here as the placeholder.
sensitiveInfo := make([]bool, len(columnNames))
- return []interface{}{columnNames, columnTypeNames, data, sensitiveInfo}, nil
+ return []any{columnNames, columnTypeNames, data, sensitiveInfo}, nil
}
-func (d *Driver) queryAdmin(ctx context.Context, statement string) ([]interface{}, error) {
+func (d *Driver) queryAdmin(ctx context.Context, statement string) ([]any, error) {
if isDDL(statement) {
op, err := d.dbClient.UpdateDatabaseDdl(ctx, &databasepb.UpdateDatabaseDdlRequest{
Database: getDSN(d.config.Host, d.dbName),
@@ -276,8 +276,8 @@ func (d *Driver) queryAdmin(ctx context.Context, statement string) ([]interface{
field := []string{"Affected Rows"}
types := []string{"INT64"}
- rows := [][]interface{}{{rowCount}}
- return []interface{}{field, types, rows}, nil
+ rows := [][]any{{rowCount}}
+ return []any{field, types, rows}, nil
}
func getColumnNames(iter *spanner.RowIterator) []string {
@@ -313,8 +313,8 @@ func getColumnTypeName(columnType *sppb.Type) (string, error) {
return columnType.Code.String(), nil
}
-func readRow(row *spanner.Row) ([]interface{}, error) {
- dest := make([]interface{}, row.Size())
+func readRow(row *spanner.Row) ([]any, error) {
+ dest := make([]any, row.Size())
for i := 0; i < row.Size(); i++ {
var col spanner.GenericColumnValue
if err := row.Column(i, &col); err != nil {
diff --git a/backend/plugin/db/sqlite/dump.go b/backend/plugin/db/sqlite/dump.go
index 51f4010a92..68acd1fb31 100644
--- a/backend/plugin/db/sqlite/dump.go
+++ b/backend/plugin/db/sqlite/dump.go
@@ -119,7 +119,7 @@ func exportTableData(txn *sql.Tx, tblName string, out io.Writer) error {
return nil
}
values := make([]*sql.NullString, len(cols))
- refs := make([]interface{}, len(cols))
+ refs := make([]any, len(cols))
for i := 0; i < len(cols); i++ {
refs[i] = &values[i]
}
diff --git a/backend/plugin/db/sqlite/migrate.go b/backend/plugin/db/sqlite/migrate.go
index 436816a4e0..3e5a615366 100644
--- a/backend/plugin/db/sqlite/migrate.go
+++ b/backend/plugin/db/sqlite/migrate.go
@@ -248,7 +248,7 @@ func (driver *Driver) FindMigrationHistoryList(ctx context.Context, find *db.Mig
issue_id,
payload
FROM bytebase_migration_history `
- paramNames, params := []string{}, []interface{}{}
+ paramNames, params := []string{}, []any{}
if v := find.ID; v != nil {
paramNames, params = append(paramNames, "id"), append(params, *v)
}
diff --git a/backend/plugin/db/sqlite/sqlite.go b/backend/plugin/db/sqlite/sqlite.go
index 96b76ca549..0e2062f493 100644
--- a/backend/plugin/db/sqlite/sqlite.go
+++ b/backend/plugin/db/sqlite/sqlite.go
@@ -186,6 +186,6 @@ func (driver *Driver) Execute(ctx context.Context, statement string, _ bool) (in
}
// QueryConn querys a SQL statement in a given connection.
-func (*Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext *db.QueryContext) ([]interface{}, error) {
+func (*Driver) QueryConn(ctx context.Context, conn *sql.Conn, statement string, queryContext *db.QueryContext) ([]any, error) {
return util.Query(ctx, db.SQLite, conn, statement, queryContext)
}
diff --git a/backend/plugin/db/util/driverutil.go b/backend/plugin/db/util/driverutil.go
index ddec8e9e57..c23934e91f 100644
--- a/backend/plugin/db/util/driverutil.go
+++ b/backend/plugin/db/util/driverutil.go
@@ -361,7 +361,7 @@ func EndMigration(ctx context.Context, executor MigrationExecutor, startedNs int
// Query will execute a readonly / SELECT query.
// The result is then JSON marshaled and returned to the frontend.
-func Query(ctx context.Context, dbType db.Type, conn *sql.Conn, statement string, queryContext *db.QueryContext) ([]interface{}, error) {
+func Query(ctx context.Context, dbType db.Type, conn *sql.Conn, statement string, queryContext *db.QueryContext) ([]any, error) {
readOnly := queryContext.ReadOnly
limit := queryContext.Limit
if !readOnly {
@@ -443,11 +443,11 @@ func Query(ctx context.Context, dbType db.Type, conn *sql.Conn, statement string
return nil, err
}
- return []interface{}{columnNames, columnTypeNames, data, fieldMaskInfo}, nil
+ return []any{columnNames, columnTypeNames, data, fieldMaskInfo}, nil
}
// query will execute a query.
-func queryAdmin(ctx context.Context, dbType db.Type, conn *sql.Conn, statement string, _ int) ([]interface{}, error) {
+func queryAdmin(ctx context.Context, dbType db.Type, conn *sql.Conn, statement string, _ int) ([]any, error) {
rows, err := conn.QueryContext(ctx, statement)
if err != nil {
return nil, FormatErrorWithQuery(err, statement)
@@ -483,16 +483,16 @@ func queryAdmin(ctx context.Context, dbType db.Type, conn *sql.Conn, statement s
// queryAdmin doesn't mask the sensitive fields.
// Return the all false boolean slice here as the placeholder.
sensitiveInfo := make([]bool, len(columnNames))
- return []interface{}{columnNames, columnTypeNames, data, sensitiveInfo}, nil
+ return []any{columnNames, columnTypeNames, data, sensitiveInfo}, nil
}
-func readRows(rows *sql.Rows, dbType db.Type, columnTypes []*sql.ColumnType, columnTypeNames []string, fieldList []db.SensitiveField) ([]interface{}, error) {
+func readRows(rows *sql.Rows, dbType db.Type, columnTypes []*sql.ColumnType, columnTypeNames []string, fieldList []db.SensitiveField) ([]any, error) {
if dbType == db.ClickHouse {
return readRowsForClickhouse(rows, columnTypes, columnTypeNames, fieldList)
}
- data := []interface{}{}
+ data := []any{}
for rows.Next() {
- scanArgs := make([]interface{}, len(columnTypes))
+ scanArgs := make([]any, len(columnTypes))
for i, v := range columnTypeNames {
// TODO(steven need help): Consult a common list of data types from database driver documentation. e.g. MySQL,PostgreSQL.
switch v {
@@ -513,7 +513,7 @@ func readRows(rows *sql.Rows, dbType db.Type, columnTypes []*sql.ColumnType, col
return nil, FormatError(err)
}
- rowData := []interface{}{}
+ rowData := []any{}
for i := range columnTypes {
if len(fieldList) > 0 && fieldList[i].Sensitive {
rowData = append(rowData, "******")
@@ -599,7 +599,7 @@ func getMSSQLStatementWithResultLimit(stmt string, limit int) string {
}
// FindMigrationHistoryList will find the list of migration history.
-func FindMigrationHistoryList(ctx context.Context, findMigrationHistoryListQuery string, queryParams []interface{}, driver db.Driver, database string) ([]*db.MigrationHistory, error) {
+func FindMigrationHistoryList(ctx context.Context, findMigrationHistoryListQuery string, queryParams []any, driver db.Driver, database string) ([]*db.MigrationHistory, error) {
// To support `pg` option, the util layer will not know which database where `migration_history` table is,
// so we need to connect to the database provided by params.
sqldb, err := driver.GetDBConnection(ctx, database)
@@ -757,18 +757,18 @@ func ConvertYesNo(s string) (bool, error) {
}
}
-func readRowsForClickhouse(rows *sql.Rows, columnTypes []*sql.ColumnType, columnTypeNames []string, fieldList []db.SensitiveField) ([]interface{}, error) {
- data := []interface{}{}
+func readRowsForClickhouse(rows *sql.Rows, columnTypes []*sql.ColumnType, columnTypeNames []string, fieldList []db.SensitiveField) ([]any, error) {
+ data := []any{}
for rows.Next() {
- cols := make([]interface{}, len(columnTypes))
+ cols := make([]any, len(columnTypes))
for i, name := range columnTypeNames {
// The ClickHouse driver uses *Type rather than sql.NullType to scan nullable fields
// as described in https://github.com/ClickHouse/clickhouse-go/issues/754
// TODO: remove this workaround once fixed.
if strings.HasPrefix(name, "TUPLE") || strings.HasPrefix(name, "ARRAY") || strings.HasPrefix(name, "MAP") {
- // For TUPLE, ARRAY, MAP type in ClickHouse, we pass interface{} and the driver will do the rest.
- var it interface{}
+ // For TUPLE, ARRAY, MAP type in ClickHouse, we pass any and the driver will do the rest.
+ var it any
cols[i] = &it
} else {
// We use ScanType to get the correct *Type and then do type assertions
@@ -781,7 +781,7 @@ func readRowsForClickhouse(rows *sql.Rows, columnTypes []*sql.ColumnType, column
return nil, FormatError(err)
}
- rowData := []interface{}{}
+ rowData := []any{}
for i := range cols {
if len(fieldList) > 0 && fieldList[i].Sensitive {
rowData = append(rowData, "******")
@@ -789,7 +789,7 @@ func readRowsForClickhouse(rows *sql.Rows, columnTypes []*sql.ColumnType, column
}
// handle TUPLE ARRAY MAP
- if v, ok := cols[i].(*interface{}); ok && v != nil {
+ if v, ok := cols[i].(*any); ok && v != nil {
rowData = append(rowData, *v)
continue
}
diff --git a/backend/plugin/metric/metric.go b/backend/plugin/metric/metric.go
index 80c6581500..dbbfb534fd 100644
--- a/backend/plugin/metric/metric.go
+++ b/backend/plugin/metric/metric.go
@@ -8,7 +8,7 @@ type Name string
type Metric struct {
Name Name
Value int
- Labels map[string]interface{}
+ Labels map[string]any
}
// Identifier is the identifier for metric.
diff --git a/backend/plugin/parser/edit/mysql/deparse.go b/backend/plugin/parser/edit/mysql/deparse.go
index 7a94c94cdb..ee0331cfd3 100644
--- a/backend/plugin/parser/edit/mysql/deparse.go
+++ b/backend/plugin/parser/edit/mysql/deparse.go
@@ -292,7 +292,7 @@ func transformAddColumnContext(addColumnContext *api.AddColumnContext) (*tidbast
if addColumnContext.Comment != "" {
columnOptionList = append(columnOptionList, &tidbast.ColumnOption{
Tp: tidbast.ColumnOptionComment,
- Expr: tidbast.NewValueExpr(interface{}(addColumnContext.Comment), addColumnContext.CharacterSet, addColumnContext.Collation),
+ Expr: tidbast.NewValueExpr(any(addColumnContext.Comment), addColumnContext.CharacterSet, addColumnContext.Collation),
})
}
if addColumnContext.Collation != "" {
@@ -304,7 +304,7 @@ func transformAddColumnContext(addColumnContext *api.AddColumnContext) (*tidbast
if addColumnContext.Default != nil {
columnOptionList = append(columnOptionList, &tidbast.ColumnOption{
Tp: tidbast.ColumnOptionDefaultValue,
- Expr: tidbast.NewValueExpr(interface{}(*addColumnContext.Default), addColumnContext.CharacterSet, addColumnContext.Collation),
+ Expr: tidbast.NewValueExpr(any(*addColumnContext.Default), addColumnContext.CharacterSet, addColumnContext.Collation),
})
}
if !addColumnContext.Nullable {
@@ -335,7 +335,7 @@ func transformChangeColumnContext(changeColumnContext *api.ChangeColumnContext)
if changeColumnContext.Comment != "" {
columnOptionList = append(columnOptionList, &tidbast.ColumnOption{
Tp: tidbast.ColumnOptionComment,
- Expr: tidbast.NewValueExpr(interface{}(changeColumnContext.Comment), changeColumnContext.CharacterSet, changeColumnContext.Collation),
+ Expr: tidbast.NewValueExpr(any(changeColumnContext.Comment), changeColumnContext.CharacterSet, changeColumnContext.Collation),
})
}
if changeColumnContext.Collation != "" {
@@ -352,7 +352,7 @@ func transformChangeColumnContext(changeColumnContext *api.ChangeColumnContext)
if changeColumnContext.Default != nil {
columnOptionList = append(columnOptionList, &tidbast.ColumnOption{
Tp: tidbast.ColumnOptionDefaultValue,
- Expr: tidbast.NewValueExpr(interface{}(*changeColumnContext.Default), changeColumnContext.CharacterSet, changeColumnContext.Collation),
+ Expr: tidbast.NewValueExpr(any(*changeColumnContext.Default), changeColumnContext.CharacterSet, changeColumnContext.Collation),
})
}
columnDef.Options = columnOptionList
diff --git a/backend/plugin/parser/error.go b/backend/plugin/parser/error.go
index b793894912..d8a78cbbaf 100644
--- a/backend/plugin/parser/error.go
+++ b/backend/plugin/parser/error.go
@@ -17,6 +17,6 @@ func (e *ConvertError) Error() string {
}
// NewConvertErrorf returns the new conversion error.
-func NewConvertErrorf(format string, a ...interface{}) *ConvertError {
+func NewConvertErrorf(format string, a ...any) *ConvertError {
return &ConvertError{err: errors.Errorf(format, a...)}
}
diff --git a/backend/plugin/parser/validate_sql_for_editor.go b/backend/plugin/parser/validate_sql_for_editor.go
index 7c67a08509..daf857ba2b 100644
--- a/backend/plugin/parser/validate_sql_for_editor.go
+++ b/backend/plugin/parser/validate_sql_for_editor.go
@@ -85,7 +85,7 @@ func postgresValidateSQLForEditor(statement string) bool {
cteRegex := regexp.MustCompile(`^WITH\s+?`)
if matchResult := cteRegex.MatchString(formattedStr); matchResult {
- var jsonData map[string]interface{}
+ var jsonData map[string]any
if err := json.Unmarshal([]byte(jsonText), &jsonData); err != nil {
log.Debug("Failed to unmarshal JSON", zap.String("jsonText", jsonText), zap.Error(err))
@@ -100,7 +100,7 @@ func postgresValidateSQLForEditor(statement string) bool {
return false
}
-func keyExistsInJSONData(jsonData map[string]interface{}, keyList []string) bool {
+func keyExistsInJSONData(jsonData map[string]any, keyList []string) bool {
for _, key := range keyList {
if _, ok := jsonData[key]; ok {
return true
@@ -109,13 +109,13 @@ func keyExistsInJSONData(jsonData map[string]interface{}, keyList []string) bool
for _, value := range jsonData {
switch v := value.(type) {
- case map[string]interface{}:
+ case map[string]any:
if keyExistsInJSONData(v, keyList) {
return true
}
- case []interface{}:
+ case []any:
for _, item := range v {
- if m, ok := item.(map[string]interface{}); ok {
+ if m, ok := item.(map[string]any); ok {
if keyExistsInJSONData(m, keyList) {
return true
}
diff --git a/backend/plugin/vcs/gitlab/sql_review.go b/backend/plugin/vcs/gitlab/sql_review.go
index 09cc52657d..1ee104a660 100644
--- a/backend/plugin/vcs/gitlab/sql_review.go
+++ b/backend/plugin/vcs/gitlab/sql_review.go
@@ -32,14 +32,14 @@ func SetupSQLReviewCI(endpoint string) string {
}
// SetupGitLabCI will update the GitLab CI content to add or update the SQL review CI.
-func SetupGitLabCI(gitlabCI map[string]interface{}) (string, error) {
+func SetupGitLabCI(gitlabCI map[string]any) (string, error) {
// Add include for SQL review CI
- var includeList []interface{}
+ var includeList []any
// Docs for GitLab include syntax: https://docs.gitlab.com/ee/ci/yaml/includes.html
switch include := gitlabCI[gitlabCIIncludeKeyword].(type) {
- case []interface{}:
+ case []any:
includeList = append(includeList, include...)
- case string, interface{}:
+ case string, any:
includeList = append(includeList, include)
}
@@ -56,9 +56,9 @@ func SetupGitLabCI(gitlabCI map[string]interface{}) (string, error) {
return string(newContent), nil
}
-func findSQLReviewCI(include []interface{}) (map[string]interface{}, bool) {
+func findSQLReviewCI(include []any) (map[string]any, bool) {
for _, data := range include {
- if val, ok := data.(map[string]interface{}); ok {
+ if val, ok := data.(map[string]any); ok {
if val[sqlReviewCIFileRelativePathKeywordInGitLabCI] == SQLReviewCIFilePath {
return val, true
}
diff --git a/backend/plugin/vcs/gitlab/sql_review_test.go b/backend/plugin/vcs/gitlab/sql_review_test.go
index 790ddb460b..40230e646f 100644
--- a/backend/plugin/vcs/gitlab/sql_review_test.go
+++ b/backend/plugin/vcs/gitlab/sql_review_test.go
@@ -22,7 +22,7 @@ after_script:
`
func Test_SetupGitLabCI(t *testing.T) {
- content := make(map[string]interface{})
+ content := make(map[string]any)
err := yaml.Unmarshal([]byte(mockGitLabCIContentYAMLStr), &content)
require.NoError(t, err)
@@ -37,7 +37,7 @@ func Test_SetupGitLabCI(t *testing.T) {
assert.NotNil(t, content["before_script"])
assert.NotNil(t, content["after_script"])
- include, ok := content["include"].([]interface{})
+ include, ok := content["include"].([]any)
assert.Equal(t, ok, true)
sqlReviewCI, ok := findSQLReviewCI(include)
diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.go
index 0d4e847e0a..2f1362ff07 100644
--- a/backend/runner/approval/runner.go
+++ b/backend/runner/approval/runner.go
@@ -239,7 +239,7 @@ func getApprovalTemplate(approvalSetting *storepb.WorkspaceApprovalSetting, risk
return nil, errors.Wrap(err, "failed to compile expression")
}
- res, _, err := prg.Eval(map[string]interface{}{
+ res, _, err := prg.Eval(map[string]any{
"level": riskLevel,
"source": int64(convertToSource(riskSource)),
})
@@ -388,7 +388,7 @@ func getTaskRiskLevel(ctx context.Context, s *store.Store, issue *store.IssueMes
if err != nil {
return 0, false, err
}
- args := map[string]interface{}{
+ args := map[string]any{
"environment_id": instance.EnvironmentID,
"project_id": issue.Project.ResourceID,
"database_name": databaseName,
diff --git a/backend/runner/taskcheck/statement_affected_rows_report_executor.go b/backend/runner/taskcheck/statement_affected_rows_report_executor.go
index 824b8ac84b..5bffc742b8 100644
--- a/backend/runner/taskcheck/statement_affected_rows_report_executor.go
+++ b/backend/runner/taskcheck/statement_affected_rows_report_executor.go
@@ -176,14 +176,14 @@ func getUpdateOrDeleteAffectedRowsForPostgres(ctx context.Context, sqlDB *sql.DB
return rowCount, nil
}
-func getAffectedRowsCountForPostgres(res []interface{}) (int64, error) {
- // the res struct is []interface{}{columnName, columnTable, rowDataList}
+func getAffectedRowsCountForPostgres(res []any) (int64, error) {
+ // the res struct is []any{columnName, columnTable, rowDataList}
if len(res) != 3 {
return 0, errors.Errorf("expected 3 but got %d", len(res))
}
- rowList, ok := res[2].([]interface{})
+ rowList, ok := res[2].([]any)
if !ok {
- return 0, errors.Errorf("expected []interface{} but got %t", res[2])
+ return 0, errors.Errorf("expected []any but got %t", res[2])
}
// test-bb=# EXPLAIN INSERT INTO t SELECT * FROM t;
// QUERY PLAN
@@ -195,9 +195,9 @@ func getAffectedRowsCountForPostgres(res []interface{}) (int64, error) {
return 0, errors.Errorf("not found any data")
}
// We need the row 2.
- rowTwo, ok := rowList[1].([]interface{})
+ rowTwo, ok := rowList[1].([]any)
if !ok {
- return 0, errors.Errorf("expected []interface{} but got %t", rowList[0])
+ return 0, errors.Errorf("expected []any but got %t", rowList[0])
}
// PostgreSQL EXPLAIN statement result has one column.
if len(rowTwo) != 1 {
@@ -344,21 +344,21 @@ func getUpdateOrDeleteAffectedRowsForMysql(ctx context.Context, sqlDB *sql.DB, n
return rowCount, nil
}
-func getUpdateOrDeleteAffectedRowsCountForMysql(res []interface{}) (int64, error) {
- // the res struct is []interface{}{columnName, columnTable, rowDataList}
+func getUpdateOrDeleteAffectedRowsCountForMysql(res []any) (int64, error) {
+ // the res struct is []any{columnName, columnTable, rowDataList}
if len(res) != 3 {
return 0, errors.Errorf("expected 3 but got %d", len(res))
}
- rowList, ok := res[2].([]interface{})
+ rowList, ok := res[2].([]any)
if !ok {
- return 0, errors.Errorf("expected []interface{} but got %t", res[2])
+ return 0, errors.Errorf("expected []any but got %t", res[2])
}
if len(rowList) < 1 {
return 0, errors.Errorf("not found any data")
}
- rowOne, ok := rowList[0].([]interface{})
+ rowOne, ok := rowList[0].([]any)
if !ok {
- return 0, errors.Errorf("expected []interface{} but got %t", rowList[0])
+ return 0, errors.Errorf("expected []any but got %t", rowList[0])
}
// MySQL EXPLAIN statement result has 12 columns.
//
@@ -388,14 +388,14 @@ func getUpdateOrDeleteAffectedRowsCountForMysql(res []interface{}) (int64, error
}
}
-func getInsertAffectedRowsCountForMysql(res []interface{}) (int64, error) {
- // the res struct is []interface{}{columnName, columnTable, rowDataList}
+func getInsertAffectedRowsCountForMysql(res []any) (int64, error) {
+ // the res struct is []any{columnName, columnTable, rowDataList}
if len(res) != 3 {
return 0, errors.Errorf("expected 3 but got %d", len(res))
}
- rowList, ok := res[2].([]interface{})
+ rowList, ok := res[2].([]any)
if !ok {
- return 0, errors.Errorf("expected []interface{} but got %t", res[2])
+ return 0, errors.Errorf("expected []any but got %t", res[2])
}
// mysql> explain insert into td select * from td;
// +----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+-----------------+
@@ -408,9 +408,9 @@ func getInsertAffectedRowsCountForMysql(res []interface{}) (int64, error) {
return 0, errors.Errorf("not found any data")
}
// We need the row 2.
- rowTwo, ok := rowList[1].([]interface{})
+ rowTwo, ok := rowList[1].([]any)
if !ok {
- return 0, errors.Errorf("expected []interface{} but got %t", rowList[0])
+ return 0, errors.Errorf("expected []any but got %t", rowList[0])
}
// MySQL EXPLAIN statement result has 12 columns.
if len(rowTwo) != 12 {
@@ -434,7 +434,7 @@ func getInsertAffectedRowsCountForMysql(res []interface{}) (int64, error) {
}
// Query runs the EXPLAIN or SELECT statements for advisors.
-func query(ctx context.Context, connection *sql.DB, statement string) ([]interface{}, error) {
+func query(ctx context.Context, connection *sql.DB, statement string) ([]any, error) {
tx, err := connection.BeginTx(ctx, &sql.TxOptions{})
if err != nil {
return nil, err
@@ -466,9 +466,9 @@ func query(ctx context.Context, connection *sql.DB, statement string) ([]interfa
columnTypeNames = append(columnTypeNames, strings.ToUpper(v.DatabaseTypeName()))
}
- data := []interface{}{}
+ data := []any{}
for rows.Next() {
- scanArgs := make([]interface{}, colCount)
+ scanArgs := make([]any, colCount)
for i, v := range columnTypeNames {
// TODO(steven need help): Consult a common list of data types from database driver documentation. e.g. MySQL,PostgreSQL.
switch v {
@@ -489,7 +489,7 @@ func query(ctx context.Context, connection *sql.DB, statement string) ([]interfa
return nil, err
}
- rowData := []interface{}{}
+ rowData := []any{}
for i := range columnTypes {
if v, ok := (scanArgs[i]).(*sql.NullBool); ok && v.Valid {
rowData = append(rowData, v.Bool)
@@ -521,5 +521,5 @@ func query(ctx context.Context, connection *sql.DB, statement string) ([]interfa
return nil, err
}
- return []interface{}{columnNames, columnTypeNames, data}, nil
+ return []any{columnNames, columnTypeNames, data}, nil
}
diff --git a/backend/runner/taskrun/scheduler.go b/backend/runner/taskrun/scheduler.go
index 2da3b58be2..fe0b7c1f6b 100644
--- a/backend/runner/taskrun/scheduler.go
+++ b/backend/runner/taskrun/scheduler.go
@@ -345,7 +345,7 @@ func (s *Scheduler) Run(ctx context.Context, wg *sync.WaitGroup) {
s.metricReporter.Report(&metric.Metric{
Name: metricAPI.TaskStatusMetricName,
Value: 1,
- Labels: map[string]interface{}{
+ Labels: map[string]any{
"type": task.Type,
"value": taskStatusPatch.Status,
},
diff --git a/backend/server/debug.go b/backend/server/debug.go
index 4c83c5db93..d23e92689b 100644
--- a/backend/server/debug.go
+++ b/backend/server/debug.go
@@ -45,7 +45,7 @@ func (s *Server) registerDebugRoutes(g *echo.Group) {
s.errorRecordRing.RWMutex.RLock()
defer s.errorRecordRing.RWMutex.RUnlock()
- s.errorRecordRing.Ring.Do(func(p interface{}) {
+ s.errorRecordRing.Ring.Do(func(p any) {
if p == nil {
return
}
diff --git a/backend/server/issue.go b/backend/server/issue.go
index 8b59cff7ad..ced5532ae7 100644
--- a/backend/server/issue.go
+++ b/backend/server/issue.go
@@ -47,7 +47,7 @@ func (s *Server) registerIssueRoutes(g *echo.Group) {
s.MetricReporter.Report(&metric.Metric{
Name: metricAPI.IssueCreateMetricName,
Value: 1,
- Labels: map[string]interface{}{
+ Labels: map[string]any{
"type": issue.Type,
},
})
@@ -1133,7 +1133,7 @@ func (s *Server) createDatabaseCreateTaskList(ctx context.Context, c api.CreateD
}
defer driver.Close(ctx)
var lowerCaseTableNames int
- var unused interface{}
+ var unused any
db, err := driver.GetDBConnection(ctx, "" /* databaseName */)
if err != nil {
log.Warn("failed to get db connection for instance %q", zap.Error(err), zap.String("instance", instance.Title))
diff --git a/backend/server/jwt.go b/backend/server/jwt.go
index 32719c402b..a6f23ba870 100644
--- a/backend/server/jwt.go
+++ b/backend/server/jwt.go
@@ -146,7 +146,7 @@ func JWTMiddleware(pathPrefix string, principalStore *store.Store, next echo.Han
}
claims := &Claims{}
- accessToken, err := jwt.ParseWithClaims(token, claims, func(t *jwt.Token) (interface{}, error) {
+ accessToken, err := jwt.ParseWithClaims(token, claims, func(t *jwt.Token) (any, error) {
if t.Method.Alg() != jwt.SigningMethodHS256.Name {
return nil, pkgerrors.Errorf("unexpected access token signing method=%v, expect %v", t.Header["alg"], jwt.SigningMethodHS256)
}
@@ -206,7 +206,7 @@ func JWTMiddleware(pathPrefix string, principalStore *store.Store, next echo.Han
// Parses token and checks if it's valid.
refreshTokenClaims := &Claims{}
- refreshToken, err := jwt.ParseWithClaims(rc.Value, refreshTokenClaims, func(t *jwt.Token) (interface{}, error) {
+ refreshToken, err := jwt.ParseWithClaims(rc.Value, refreshTokenClaims, func(t *jwt.Token) (any, error) {
if t.Method.Alg() != jwt.SigningMethodHS256.Name {
return nil, pkgerrors.Errorf("unexpected refresh token signing method=%v, expected %v", t.Header["alg"], jwt.SigningMethodHS256)
}
diff --git a/backend/server/openapi_metric.go b/backend/server/openapi_metric.go
index 7f8dce7ffa..724eabc661 100644
--- a/backend/server/openapi_metric.go
+++ b/backend/server/openapi_metric.go
@@ -23,7 +23,7 @@ func openAPIMetricMiddleware(s *Server, next echo.HandlerFunc) echo.HandlerFunc
s.MetricReporter.Report(&metric.Metric{
Name: metricAPI.OpenAPIMetricName,
Value: 1,
- Labels: map[string]interface{}{
+ Labels: map[string]any{
"latency_ns": strconv.FormatInt(duration.Nanoseconds(), 10),
"request_method": requestMethod,
"request_path": requestPath,
diff --git a/backend/server/openapi_sql.go b/backend/server/openapi_sql.go
index 94871b49bf..840c9a530f 100644
--- a/backend/server/openapi_sql.go
+++ b/backend/server/openapi_sql.go
@@ -178,7 +178,7 @@ func (s *Server) sqlCheckController(c echo.Context) error {
s.MetricReporter.Report(&metric.Metric{
Name: metricAPI.SQLAdviseAPIMetricName,
Value: 1,
- Labels: map[string]interface{}{
+ Labels: map[string]any{
"database_type": databaseType,
"environment": request.EnvironmentName,
},
diff --git a/backend/server/principal.go b/backend/server/principal.go
index b209329706..abe94b90b7 100644
--- a/backend/server/principal.go
+++ b/backend/server/principal.go
@@ -91,7 +91,7 @@ func (s *Server) registerPrincipalRoutes(g *echo.Group) {
s.MetricReporter.Report(&metric.Metric{
Name: metricAPI.PrincipalCreateMetricName,
Value: 1,
- Labels: map[string]interface{}{
+ Labels: map[string]any{
"type": principal.Type,
"role": principal.Role,
"rank": count,
diff --git a/backend/server/project.go b/backend/server/project.go
index 49d21df3a3..2dcb138210 100644
--- a/backend/server/project.go
+++ b/backend/server/project.go
@@ -1136,7 +1136,7 @@ func (s *Server) setupVCSSQLReviewCIForGitHub(ctx context.Context, repository *a
func (s *Server) setupVCSSQLReviewCIForGitLab(ctx context.Context, repository *api.Repository, branch *vcsPlugin.BranchInfo, sqlReviewEndpoint string) error {
// create or update the .gitlab-ci.yml
if err := s.createOrUpdateVCSSQLReviewFileForGitLab(ctx, repository, branch, gitlab.CIFilePath, func(fileMeta *vcsPlugin.FileMeta) (string, error) {
- content := make(map[string]interface{})
+ content := make(map[string]any)
if fileMeta != nil {
ciFileContent, err := vcsPlugin.Get(repository.VCS.Type, vcsPlugin.ProviderConfig{}).ReadFileContent(
diff --git a/backend/server/server.go b/backend/server/server.go
index 0cf64fdac8..d11eecafaf 100644
--- a/backend/server/server.go
+++ b/backend/server/server.go
@@ -367,7 +367,7 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {
s.MetricReporter.Report(&metricPlugin.Metric{
Name: metric.APIRequestMetricName,
Value: 1,
- Labels: map[string]interface{}{
+ Labels: map[string]any{
"path": c.Request().URL.Path,
"method": c.Request().Method,
},
diff --git a/backend/server/sql.go b/backend/server/sql.go
index 3c21be4b09..d1190f489d 100644
--- a/backend/server/sql.go
+++ b/backend/server/sql.go
@@ -561,7 +561,7 @@ func (s *Server) registerSQLRoutes(g *echo.Group) {
s.MetricReporter.Report(&metric.Metric{
Name: metricAPI.SQLEditorExecutionMetricName,
Value: 1,
- Labels: map[string]interface{}{
+ Labels: map[string]any{
"engine": instance.Engine,
"readonly": exec.Readonly,
"admin_mode": false,
@@ -763,7 +763,7 @@ func (s *Server) registerSQLRoutes(g *echo.Group) {
s.MetricReporter.Report(&metric.Metric{
Name: metricAPI.SQLEditorExecutionMetricName,
Value: 1,
- Labels: map[string]interface{}{
+ Labels: map[string]any{
"engine": instance.Engine,
"readonly": exec.Readonly,
"admin_mode": true,
diff --git a/backend/sql-server/advise.go b/backend/sql-server/advise.go
index e8ca817645..13c2904f90 100644
--- a/backend/sql-server/advise.go
+++ b/backend/sql-server/advise.go
@@ -118,7 +118,7 @@ func (s *Server) sqlCheckController(c echo.Context) error {
s.metricReporter.Report(&metric.Metric{
Name: metricAPI.SQLAdviseAPIMetricName,
Value: 1,
- Labels: map[string]interface{}{
+ Labels: map[string]any{
"database_type": string(advisorDBType),
"platform": c.Request().Header.Get("X-Platform"),
"repository": c.Request().Header.Get("X-Repository"),
diff --git a/backend/sql-server/metric.go b/backend/sql-server/metric.go
index 24b32ce42f..dbb6a2356f 100644
--- a/backend/sql-server/metric.go
+++ b/backend/sql-server/metric.go
@@ -44,7 +44,7 @@ func metricMiddleware(s *Server, next echo.HandlerFunc) echo.HandlerFunc {
s.metricReporter.Report(&metric.Metric{
Name: metricAPI.OpenAPIMetricName,
Value: 1,
- Labels: map[string]interface{}{
+ Labels: map[string]any{
"latency_ns": strconv.FormatInt(duration.Nanoseconds(), 10),
"request_method": requestMethod,
"request_path": requestPath,
diff --git a/backend/store/activity.go b/backend/store/activity.go
index cc5add2fe9..3c34de3dd3 100644
--- a/backend/store/activity.go
+++ b/backend/store/activity.go
@@ -265,7 +265,7 @@ func (s *Store) composeActivity(ctx context.Context, raw *activityRaw) (*api.Act
// createActivityImpl creates activities.
func createActivityImpl(ctx context.Context, tx *Tx, creates ...*api.ActivityCreate) ([]*activityRaw, error) {
var query strings.Builder
- var values []interface{}
+ var values []any
var queryValues []string
if _, err := query.WriteString(
@@ -344,7 +344,7 @@ func createActivityImpl(ctx context.Context, tx *Tx, creates ...*api.ActivityCre
func findActivityImpl(ctx context.Context, tx *Tx, find *api.ActivityFind) ([]*activityRaw, error) {
// Build WHERE clause.
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.ID; v != nil {
where, args = append(where, fmt.Sprintf("id = $%d", len(args)+1)), append(args, *v)
}
@@ -440,7 +440,7 @@ func findActivityImpl(ctx context.Context, tx *Tx, find *api.ActivityFind) ([]*a
// patchActivityImpl updates a activity by ID. Returns the new state of the activity after update.
func patchActivityImpl(ctx context.Context, tx *Tx, patch *api.ActivityPatch) (*activityRaw, error) {
// Build UPDATE clause.
- set, args := []string{"updater_id = $1"}, []interface{}{patch.UpdaterID}
+ set, args := []string{"updater_id = $1"}, []any{patch.UpdaterID}
if v := patch.Comment; v != nil {
set, args = append(set, fmt.Sprintf("comment = $%d", len(args)+1)), append(args, api.Role(*v))
}
diff --git a/backend/store/anomaly.go b/backend/store/anomaly.go
index c2103e4a8c..3fb40575ec 100644
--- a/backend/store/anomaly.go
+++ b/backend/store/anomaly.go
@@ -237,7 +237,7 @@ func (*Store) createAnomalyImplV2(ctx context.Context, tx *Tx, principalUID int,
}
func (*Store) listAnomalyImplV2(ctx context.Context, tx *Tx, list *ListAnomalyMessage) ([]*AnomalyMessage, error) {
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := list.RowStatus; v != nil {
where, args = append(where, fmt.Sprintf("row_status = $%d", len(args)+1)), append(args, *v)
}
@@ -313,7 +313,7 @@ func updateAnomalyV2(ctx context.Context, tx *Tx, principalUID int, update *upda
if update.Payload == "" {
update.Payload = "{}"
}
- set, args := []string{"updater_id = $1"}, []interface{}{principalUID}
+ set, args := []string{"updater_id = $1"}, []any{principalUID}
set, args = append(set, "payload = $2"), append(args, update.Payload)
args = append(args, update.ID)
diff --git a/backend/store/backup.go b/backend/store/backup.go
index 4a53e8f2fb..7d95ddb152 100644
--- a/backend/store/backup.go
+++ b/backend/store/backup.go
@@ -626,7 +626,7 @@ func (s *Store) ListBackupV2(ctx context.Context, find *FindBackupMessage) ([]*B
// UpdateBackupV2 patches an instance of Backup.
func (s *Store) UpdateBackupV2(ctx context.Context, patch *UpdateBackupMessage) (*BackupMessage, error) {
// Build UPDATE clause.
- set, args := []string{"updater_id = $1"}, []interface{}{patch.UpdaterID}
+ set, args := []string{"updater_id = $1"}, []any{patch.UpdaterID}
if v := patch.RowStatus; v != nil {
set, args = append(set, fmt.Sprintf("row_status = $%d", len(args)+1)), append(args, *v)
}
@@ -693,7 +693,7 @@ func (s *Store) UpdateBackupV2(ctx context.Context, patch *UpdateBackupMessage)
func (*Store) listBackupImplV2(ctx context.Context, tx *Tx, find *FindBackupMessage) ([]*BackupMessage, error) {
// Build where clause.
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.DatabaseUID; v != nil {
where, args = append(where, fmt.Sprintf("database_id = $%d", len(args)+1)), append(args, *v)
}
@@ -766,7 +766,7 @@ func (*Store) listBackupImplV2(ctx context.Context, tx *Tx, find *FindBackupMess
func (*Store) listBackupSettingImplV2(ctx context.Context, tx *Tx, find *FindBackupSettingMessage) ([]*BackupSettingMessage, error) {
// Build WHERE and JOIN clause.
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
var join []string
if v := find.DatabaseUID; v != nil {
where, args = append(where, fmt.Sprintf("backup_setting.database_id = $%d", len(args)+1)), append(args, *v)
diff --git a/backend/store/bookmark.go b/backend/store/bookmark.go
index 445cc79af3..e0f5d02aee 100644
--- a/backend/store/bookmark.go
+++ b/backend/store/bookmark.go
@@ -136,7 +136,7 @@ func (s *Store) GetBookmarkV2(ctx context.Context, bookmarkUID int) (*BookmarkMe
// DeleteBookmarkV2 try to delete a bookmark.
func (s *Store) DeleteBookmarkV2(ctx context.Context, bookmarkUID int) error {
- var args []interface{}
+ var args []any
var where []string
where, args = append(where, fmt.Sprintf("id = $%d", len(args)+1)), append(args, bookmarkUID)
@@ -167,7 +167,7 @@ func (s *Store) DeleteBookmarkV2(ctx context.Context, bookmarkUID int) error {
}
func (*Store) listBookmarkImplV2(ctx context.Context, tx *Tx, list *listBookmarkMessage) ([]*BookmarkMessage, error) {
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := list.creatorUID; v != nil {
where, args = append(where, fmt.Sprintf("creator_id = $%d", len(args)+1)), append(args, *v)
}
diff --git a/backend/store/data_source.go b/backend/store/data_source.go
index 33de17aa4d..d63a3975f3 100644
--- a/backend/store/data_source.go
+++ b/backend/store/data_source.go
@@ -185,7 +185,7 @@ func (s *Store) RemoveDataSourceV2(ctx context.Context, instanceUID int, environ
// UpdateDataSourceV2 updates a data source and returns the instance.
func (s *Store) UpdateDataSourceV2(ctx context.Context, patch *UpdateDataSourceMessage) error {
- set, args := []string{"updater_id = $1"}, []interface{}{fmt.Sprintf("%d", patch.UpdaterID)}
+ set, args := []string{"updater_id = $1"}, []any{fmt.Sprintf("%d", patch.UpdaterID)}
if v := patch.Username; v != nil {
set, args = append(set, fmt.Sprintf("username = $%d", len(args)+1)), append(args, *v)
diff --git a/backend/store/database.go b/backend/store/database.go
index 450e033f03..00f43792da 100644
--- a/backend/store/database.go
+++ b/backend/store/database.go
@@ -402,7 +402,7 @@ func (s *Store) UpdateDatabase(ctx context.Context, patch *UpdateDatabaseMessage
return nil, err
}
- set, args := []string{"updater_id = $1"}, []interface{}{fmt.Sprintf("%d", updaterID)}
+ set, args := []string{"updater_id = $1"}, []any{fmt.Sprintf("%d", updaterID)}
if v := patch.ProjectID; v != nil {
project, err := s.GetProjectV2(ctx, &FindProjectMessage{ResourceID: patch.ProjectID})
if err != nil {
@@ -486,7 +486,7 @@ func (s *Store) BatchUpdateDatabaseProject(ctx context.Context, databases []*Dat
defer tx.Rollback()
var wheres []string
- args := []interface{}{project.UID, updaterID}
+ args := []any{project.UID, updaterID}
for i, database := range databases {
wheres = append(wheres, fmt.Sprintf("(environment.resource_id = $%d AND instance.resource_id = $%d AND db.name = $%d)", 3*i+3, 3*i+4, 3*i+5))
args = append(args, database.EnvironmentID, database.InstanceID, database.DatabaseName)
@@ -532,7 +532,7 @@ func (s *Store) getDatabaseImplV2(ctx context.Context, tx *Tx, find *FindDatabas
}
func (*Store) listDatabaseImplV2(ctx context.Context, tx *Tx, find *FindDatabaseMessage) ([]*DatabaseMessage, error) {
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if !find.IncludeAllDatabase {
where, args = append(where, fmt.Sprintf("db.name != $%d", len(args)+1)), append(args, api.AllDatabaseName)
}
diff --git a/backend/store/db_schema.go b/backend/store/db_schema.go
index e9957a4235..a529506d10 100644
--- a/backend/store/db_schema.go
+++ b/backend/store/db_schema.go
@@ -24,7 +24,7 @@ func (s *Store) GetDBSchema(ctx context.Context, databaseID int) (*DBSchema, err
}
// Build WHERE clause.
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
where, args = append(where, fmt.Sprintf("database_id = $%d", len(args)+1)), append(args, databaseID)
tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})
diff --git a/backend/store/deploy.go b/backend/store/deploy.go
index 63f0006dba..a7e6884a07 100644
--- a/backend/store/deploy.go
+++ b/backend/store/deploy.go
@@ -122,7 +122,7 @@ func (s *Store) GetDeploymentConfigV2(ctx context.Context, projectUID int) (*Dep
if deploymentConfig, ok := s.projectIDDeploymentConfigCache.Load(projectUID); ok {
return deploymentConfig.(*DeploymentConfigMessage), nil
}
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
where, args = append(where, fmt.Sprintf("project_id = $%d", len(args)+1)), append(args, projectUID)
var deploymentConfig DeploymentConfigMessage
diff --git a/backend/store/environment.go b/backend/store/environment.go
index 444f578863..306c418a37 100644
--- a/backend/store/environment.go
+++ b/backend/store/environment.go
@@ -304,7 +304,7 @@ func (s *Store) CreateEnvironmentV2(ctx context.Context, create *EnvironmentMess
// UpdateEnvironmentV2 updates an environment.
func (s *Store) UpdateEnvironmentV2(ctx context.Context, environmentID string, patch *UpdateEnvironmentMessage, updaterID int) (*EnvironmentMessage, error) {
- set, args := []string{"updater_id = $1"}, []interface{}{fmt.Sprintf("%d", updaterID)}
+ set, args := []string{"updater_id = $1"}, []any{fmt.Sprintf("%d", updaterID)}
if v := patch.Name; v != nil {
set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)
}
@@ -392,7 +392,7 @@ func (*Store) getEnvironmentImplV2(ctx context.Context, tx *Tx, find *FindEnviro
}
func listEnvironmentImplV2(ctx context.Context, tx *Tx, find *FindEnvironmentMessage) ([]*EnvironmentMessage, error) {
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.ResourceID; v != nil {
where, args = append(where, fmt.Sprintf("environment.resource_id = $%d", len(args)+1)), append(args, *v)
}
diff --git a/backend/store/external_approval.go b/backend/store/external_approval.go
index 3d55e0a4ec..96a62f9027 100644
--- a/backend/store/external_approval.go
+++ b/backend/store/external_approval.go
@@ -134,7 +134,7 @@ func (s *Store) GetExternalApprovalByIssueIDV2(ctx context.Context, issueID int)
// UpdateExternalApprovalV2 updates an ExternalApproval.
func (s *Store) UpdateExternalApprovalV2(ctx context.Context, update *UpdateExternalApprovalMessage) (*ExternalApprovalMessage, error) {
- set, args := []string{"row_status = $1"}, []interface{}{update.RowStatus}
+ set, args := []string{"row_status = $1"}, []any{update.RowStatus}
if v := update.Payload; v != nil {
set, args = append(set, fmt.Sprintf("payload = $%d", len(args)+1)), append(args, *v)
}
@@ -169,7 +169,7 @@ func (s *Store) UpdateExternalApprovalV2(ctx context.Context, update *UpdateExte
}
func (*Store) findExternalApprovalImplV2(ctx context.Context, tx *Tx, find *listExternalApprovalMessage) ([]*ExternalApprovalMessage, error) {
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
where, args = append(where, fmt.Sprintf("row_status = $%d", len(args)+1)), append(args, api.Normal)
if v := find.issueUID; v != nil {
where, args = append(where, fmt.Sprintf("issue_id = $%d", len(args)+1)), append(args, *v)
diff --git a/backend/store/idp.go b/backend/store/idp.go
index 4f763eae0e..d0b86ead97 100644
--- a/backend/store/idp.go
+++ b/backend/store/idp.go
@@ -187,7 +187,7 @@ func (s *Store) UpdateIdentityProvider(ctx context.Context, patch *UpdateIdentit
}
func (*Store) updateIdentityProviderImpl(ctx context.Context, tx *Tx, patch *UpdateIdentityProviderMessage) (*IdentityProviderMessage, error) {
- set, args := []string{}, []interface{}{}
+ set, args := []string{}, []any{}
if v := patch.Title; v != nil {
set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)
}
@@ -250,7 +250,7 @@ func (*Store) updateIdentityProviderImpl(ctx context.Context, tx *Tx, patch *Upd
}
func (*Store) listIdentityProvidersImpl(ctx context.Context, tx *Tx, find *FindIdentityProviderMessage) ([]*IdentityProviderMessage, error) {
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.ResourceID; v != nil {
where, args = append(where, fmt.Sprintf("resource_id = $%d", len(args)+1)), append(args, *v)
}
diff --git a/backend/store/inbox.go b/backend/store/inbox.go
index c896d275ea..1a6fed4e7c 100644
--- a/backend/store/inbox.go
+++ b/backend/store/inbox.go
@@ -260,7 +260,7 @@ func (s *Store) createInboxImpl(ctx context.Context, tx *Tx, create *api.InboxCr
func findInboxImpl(ctx context.Context, tx *Tx, find *api.InboxFind) ([]*inboxRaw, error) {
// Build WHERE clause.
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
where = append(where, "inbox.activity_id = activity.id")
if v := find.ID; v != nil {
where, args = append(where, fmt.Sprintf("inbox.id = $%d", len(args)+1)), append(args, *v)
@@ -331,7 +331,7 @@ func findInboxImpl(ctx context.Context, tx *Tx, find *api.InboxFind) ([]*inboxRa
// patchInboxImpl updates a inbox by ID. Returns the new state of the inbox after update.
func (s *Store) patchInboxImpl(ctx context.Context, tx *Tx, patch *api.InboxPatch) (*inboxRaw, error) {
// Build UPDATE clause.
- set, args := []string{"status = $1"}, []interface{}{patch.Status}
+ set, args := []string{"status = $1"}, []any{patch.Status}
args = append(args, patch.ID)
var inboxRaw inboxRaw
diff --git a/backend/store/instance.go b/backend/store/instance.go
index c4c5d0c62f..0df14a359c 100644
--- a/backend/store/instance.go
+++ b/backend/store/instance.go
@@ -292,7 +292,7 @@ func (s *Store) UpdateInstanceV2(ctx context.Context, patch *UpdateInstanceMessa
}
}
- set, args := []string{"updater_id = $1"}, []interface{}{fmt.Sprintf("%d", patch.UpdaterID)}
+ set, args := []string{"updater_id = $1"}, []any{fmt.Sprintf("%d", patch.UpdaterID)}
if v := patch.Title; v != nil {
set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)
}
@@ -398,7 +398,7 @@ func (s *Store) UpdateInstanceV2(ctx context.Context, patch *UpdateInstanceMessa
}
func (s *Store) listInstanceImplV2(ctx context.Context, tx *Tx, find *FindInstanceMessage) ([]*InstanceMessage, error) {
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.EnvironmentID; v != nil {
where, args = append(where, fmt.Sprintf("environment.resource_id = $%d", len(args)+1)), append(args, *v)
}
diff --git a/backend/store/instance_change_history.go b/backend/store/instance_change_history.go
index 83569dbf85..7726ffc4bb 100644
--- a/backend/store/instance_change_history.go
+++ b/backend/store/instance_change_history.go
@@ -83,7 +83,7 @@ func (*Store) createInstanceChangeHistoryImpl(ctx context.Context, tx *Tx, creat
return nil, nil
}
var query strings.Builder
- var values []interface{}
+ var values []any
var queryValues []string
_, _ = query.WriteString(`
@@ -295,7 +295,7 @@ func (s *Store) FindInstanceChangeHistoryList(ctx context.Context, find *db.Migr
// ListInstanceChangeHistory finds the instance change history.
func (s *Store) ListInstanceChangeHistory(ctx context.Context, find *FindInstanceChangeHistoryMessage) ([]*InstanceChangeHistoryMessage, error) {
- where, args := []string{"instance_id = $1"}, []interface{}{find.InstanceID}
+ where, args := []string{"instance_id = $1"}, []any{find.InstanceID}
if v := find.ID; v != nil {
where, args = append(where, fmt.Sprintf("id = $%d", len(args)+1)), append(args, *v)
}
@@ -428,7 +428,7 @@ func (s *Store) UpdateInstanceChangeHistoryAsFailed(ctx context.Context, migrati
// UpdateInstanceChangeHistory updates an instance change history.
// it deprecates the old UpdateHistoryAsDone and UpdateHistoryAsFailed.
func (s *Store) UpdateInstanceChangeHistory(ctx context.Context, update *UpdateInstanceChangeHistoryMessage) error {
- set, args := []string{}, []interface{}{}
+ set, args := []string{}, []any{}
if v := update.Status; v != nil {
set, args = append(set, fmt.Sprintf("status = $%d", len(args)+1)), append(args, *v)
}
diff --git a/backend/store/instance_user.go b/backend/store/instance_user.go
index c09d5a800d..9fa9955051 100644
--- a/backend/store/instance_user.go
+++ b/backend/store/instance_user.go
@@ -76,7 +76,7 @@ func (s *Store) UpsertInstanceUsers(ctx context.Context, instanceUID int, instan
// Delete instance users that no longer exist.
if len(deletes) > 0 {
- deleteArgs := []interface{}{instanceUID}
+ deleteArgs := []any{instanceUID}
var deletePlaceholders []string
for i, d := range deletes {
deleteArgs = append(deleteArgs, d)
@@ -91,7 +91,7 @@ func (s *Store) UpsertInstanceUsers(ctx context.Context, instanceUID int, instan
}
// Upsert instance users.
if len(upserts) > 0 {
- args := []interface{}{}
+ args := []any{}
var placeholders []string
for i, instanceUser := range upserts {
args = append(args, api.SystemBotID, api.SystemBotID, instanceUID, instanceUser.Name, instanceUser.Grant)
@@ -148,7 +148,7 @@ func getInstanceUsersDiff(oldInstanceUsers, instanceUsers []*InstanceUserMessage
}
func listInstanceUsersImpl(ctx context.Context, tx *Tx, find *FindInstanceUserMessage) ([]*InstanceUserMessage, error) {
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
where, args = append(where, fmt.Sprintf("instance_id = $%d", len(args)+1)), append(args, find.InstanceUID)
if v := find.Name; v != nil {
diff --git a/backend/store/issue.go b/backend/store/issue.go
index 174c604633..9e6425cb7d 100644
--- a/backend/store/issue.go
+++ b/backend/store/issue.go
@@ -657,7 +657,7 @@ func (s *Store) UpdateIssueV2(ctx context.Context, uid int, patch *UpdateIssueMe
return nil, err
}
- set, args := []string{"updater_id = $1"}, []interface{}{updaterID}
+ set, args := []string{"updater_id = $1"}, []any{updaterID}
if v := patch.Title; v != nil {
set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)
}
@@ -754,7 +754,7 @@ func setSubscribers(ctx context.Context, tx *Tx, issueUID int, subscribers []*Us
}
if len(adds) > 0 {
var tokens []string
- var args []interface{}
+ var args []any
for i, v := range adds {
tokens = append(tokens, fmt.Sprintf("($%d, $%d)", 2*i+1, 2*i+2))
args = append(args, issueUID, v)
@@ -766,7 +766,7 @@ func setSubscribers(ctx context.Context, tx *Tx, issueUID int, subscribers []*Us
}
if len(deletes) > 0 {
var tokens []string
- var args []interface{}
+ var args []any
args = append(args, issueUID)
for i, v := range deletes {
tokens = append(tokens, fmt.Sprintf("$%d", i+2))
@@ -782,7 +782,7 @@ func setSubscribers(ctx context.Context, tx *Tx, issueUID int, subscribers []*Us
// ListIssueV2 returns the list of issues by find query.
func (s *Store) ListIssueV2(ctx context.Context, find *FindIssueMessage) ([]*IssueMessage, error) {
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.UID; v != nil {
where, args = append(where, fmt.Sprintf("issue.id = $%d", len(args)+1)), append(args, *v)
}
diff --git a/backend/store/pg_engine_log.go b/backend/store/pg_engine_log.go
index 35e6ff83ff..af45e21703 100644
--- a/backend/store/pg_engine_log.go
+++ b/backend/store/pg_engine_log.go
@@ -28,19 +28,19 @@ func (tx *Tx) PrepareContext(ctx context.Context, query string) (*sql.Stmt, erro
}
// ExecContext overrides sql.Tx ExecContext.
-func (tx *Tx) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) {
+func (tx *Tx) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) {
log.Debug("ExecContext", zap.String("query", cleanQuery(query)))
return tx.Tx.ExecContext(ctx, query, args...)
}
// QueryContext overrides sql.Tx QueryContext.
-func (tx *Tx) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) {
+func (tx *Tx) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) {
log.Debug("QueryContext", zap.String("query", cleanQuery(query)))
return tx.Tx.QueryContext(ctx, query, args...)
}
// QueryRowContext overrides sql.Tx QueryRowContext.
-func (tx *Tx) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row {
+func (tx *Tx) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row {
log.Debug("QueryRowContext", zap.String("query", cleanQuery(query)))
return tx.Tx.QueryRowContext(ctx, query, args...)
}
diff --git a/backend/store/pipeline.go b/backend/store/pipeline.go
index ebb4981bf5..77e859038b 100644
--- a/backend/store/pipeline.go
+++ b/backend/store/pipeline.go
@@ -84,7 +84,7 @@ func (s *Store) GetPipelineV2ByID(ctx context.Context, id int) (*PipelineMessage
// ListPipelineV2 lists pipelines.
func (s *Store) ListPipelineV2(ctx context.Context, find *PipelineFind) ([]*PipelineMessage, error) {
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.ID; v != nil {
where, args = append(where, fmt.Sprintf("pipeline.id = $%d", len(args)+1)), append(args, *v)
}
diff --git a/backend/store/policy.go b/backend/store/policy.go
index 0f1a908f18..02d19a2646 100644
--- a/backend/store/policy.go
+++ b/backend/store/policy.go
@@ -240,7 +240,7 @@ func (s *Store) CreatePolicyV2(ctx context.Context, create *PolicyMessage, creat
// UpdatePolicyV2 updates the policy.
func (s *Store) UpdatePolicyV2(ctx context.Context, patch *UpdatePolicyMessage) (*PolicyMessage, error) {
- set, args := []string{"updater_id = $1"}, []interface{}{fmt.Sprintf("%d", patch.UpdaterID)}
+ set, args := []string{"updater_id = $1"}, []any{fmt.Sprintf("%d", patch.UpdaterID)}
if v := patch.InheritFromParent; v != nil {
set, args = append(set, fmt.Sprintf("inherit_from_parent = $%d", len(args)+1)), append(args, *v)
}
@@ -368,7 +368,7 @@ func upsertPolicyV2Impl(ctx context.Context, tx *Tx, create *PolicyMessage, crea
}
func (*Store) listPolicyImplV2(ctx context.Context, tx *Tx, find *FindPolicyMessage) ([]*PolicyMessage, error) {
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.ResourceType; v != nil {
where, args = append(where, fmt.Sprintf("resource_type = $%d", len(args)+1)), append(args, *v)
}
diff --git a/backend/store/principal.go b/backend/store/principal.go
index 34cbc07354..27099de273 100644
--- a/backend/store/principal.go
+++ b/backend/store/principal.go
@@ -181,7 +181,7 @@ func (s *Store) GetUserByID(ctx context.Context, id int) (*UserMessage, error) {
}
func (*Store) listUserImpl(ctx context.Context, tx *Tx, find *FindUserMessage) ([]*UserMessage, error) {
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.ID; v != nil {
where, args = append(where, fmt.Sprintf("principal.id = $%d", len(args)+1)), append(args, *v)
}
@@ -273,7 +273,7 @@ func (s *Store) CreateUser(ctx context.Context, create *UserMessage, creatorID i
defer tx.Rollback()
set := []string{"creator_id", "updater_id", "email", "name", "type", "password_hash"}
- args := []interface{}{creatorID, creatorID, create.Email, create.Name, create.Type, create.PasswordHash}
+ args := []any{creatorID, creatorID, create.Email, create.Name, create.Type, create.PasswordHash}
placeholder := []string{}
for index := range set {
placeholder = append(placeholder, fmt.Sprintf("$%d", index+1))
@@ -346,7 +346,7 @@ func (s *Store) UpdateUser(ctx context.Context, userID int, patch *UpdateUserMes
return nil, errors.Errorf("cannot update system bot")
}
- principalSet, principalArgs := []string{"updater_id = $1"}, []interface{}{fmt.Sprintf("%d", updaterID)}
+ principalSet, principalArgs := []string{"updater_id = $1"}, []any{fmt.Sprintf("%d", updaterID)}
if v := patch.Email; v != nil {
principalSet, principalArgs = append(principalSet, fmt.Sprintf("email = $%d", len(principalArgs)+1)), append(principalArgs, strings.ToLower(*v))
}
@@ -365,7 +365,7 @@ func (s *Store) UpdateUser(ctx context.Context, userID int, patch *UpdateUserMes
}
principalArgs = append(principalArgs, userID)
- memberSet, memberArgs := []string{"updater_id = $1"}, []interface{}{fmt.Sprintf("%d", updaterID)}
+ memberSet, memberArgs := []string{"updater_id = $1"}, []any{fmt.Sprintf("%d", updaterID)}
if v := patch.Role; v != nil {
memberSet, memberArgs = append(memberSet, fmt.Sprintf("role = $%d", len(memberArgs)+1)), append(memberArgs, *v)
}
diff --git a/backend/store/project.go b/backend/store/project.go
index f2f6f75720..c08b090143 100644
--- a/backend/store/project.go
+++ b/backend/store/project.go
@@ -353,7 +353,7 @@ func (s *Store) UpdateProjectV2(ctx context.Context, patch *UpdateProjectMessage
// WARNING: calling updateProjectImplV2 from other store library has to invalidate the cache.
func (s *Store) updateProjectImplV2(ctx context.Context, tx *Tx, patch *UpdateProjectMessage) (*ProjectMessage, error) {
- set, args := []string{"updater_id = $1"}, []interface{}{fmt.Sprintf("%d", patch.UpdaterID)}
+ set, args := []string{"updater_id = $1"}, []any{fmt.Sprintf("%d", patch.UpdaterID)}
if v := patch.Title; v != nil {
set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)
}
@@ -427,7 +427,7 @@ func (s *Store) updateProjectImplV2(ctx context.Context, tx *Tx, patch *UpdatePr
}
func (s *Store) listProjectImplV2(ctx context.Context, tx *Tx, find *FindProjectMessage) ([]*ProjectMessage, error) {
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.ResourceID; v != nil {
where, args = append(where, fmt.Sprintf("resource_id = $%d", len(args)+1)), append(args, *v)
}
diff --git a/backend/store/project_member.go b/backend/store/project_member.go
index a58f1155c2..4a2ed3d953 100644
--- a/backend/store/project_member.go
+++ b/backend/store/project_member.go
@@ -193,7 +193,7 @@ func (s *Store) SetProjectIAMPolicy(ctx context.Context, set *IAMPolicyMessage,
}
func (s *Store) getProjectPolicyImpl(ctx context.Context, tx *Tx, find *GetProjectPolicyMessage) (*IAMPolicyMessage, error) {
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
where, args = append(where, fmt.Sprintf("project_member.row_status = $%d", len(args)+1)), append(args, api.Normal)
if v := find.ProjectID; v != nil {
where, args = append(where, fmt.Sprintf("project.resource_id = $%d", len(args)+1)), append(args, *v)
@@ -269,7 +269,7 @@ func (s *Store) setProjectIAMPolicyImpl(ctx context.Context, tx *Tx, set *IAMPol
}
if len(inserts.Bindings) > 0 {
- args := []interface{}{}
+ args := []any{}
var placeholders []string
for _, binding := range inserts.Bindings {
for _, member := range binding.Members {
@@ -302,7 +302,7 @@ func (*Store) deleteProjectIAMPolicyImpl(ctx context.Context, tx *Tx, projectUID
return nil
}
query := ""
- where, deletePlaceholders, args := []string{}, []string{}, []interface{}{}
+ where, deletePlaceholders, args := []string{}, []string{}, []any{}
where, args = append(where, fmt.Sprintf("(project_member.project_id = $%d)", len(args)+1)), append(args, projectUID)
for _, id := range memberIDs {
deletePlaceholders = append(deletePlaceholders, fmt.Sprintf("$%d", len(args)+1))
diff --git a/backend/store/project_webhook.go b/backend/store/project_webhook.go
index bc70cfbba1..0e6ea4bbbb 100644
--- a/backend/store/project_webhook.go
+++ b/backend/store/project_webhook.go
@@ -168,7 +168,7 @@ func (s *Store) UpdateProjectWebhookV2(ctx context.Context, principalUID int, pr
return nil, errors.Wrapf(err, "failed to begin transaction")
}
// Build UPDATE clause.
- set, args := []string{"updater_id = $1"}, []interface{}{principalUID}
+ set, args := []string{"updater_id = $1"}, []any{principalUID}
if v := update.Title; v != nil {
set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)
}
@@ -239,7 +239,7 @@ func (s *Store) DeleteProjectWebhookV2(ctx context.Context, projectUID int, proj
func (*Store) findProjectWebhookImplV2(ctx context.Context, tx *Tx, find *FindProjectWebhookMessage) ([]*ProjectWebhookMessage, error) {
// Build WHERE clause.
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.ID; v != nil {
where, args = append(where, fmt.Sprintf("id = $%d", len(args)+1)), append(args, *v)
}
diff --git a/backend/store/repository.go b/backend/store/repository.go
index 717491c92f..5846a2540c 100644
--- a/backend/store/repository.go
+++ b/backend/store/repository.go
@@ -352,7 +352,7 @@ func (s *Store) createRepositoryImpl(ctx context.Context, tx *Tx, create *api.Re
func (*Store) findRepositoryImpl(ctx context.Context, tx *Tx, find *api.RepositoryFind) ([]*repositoryRaw, error) {
// Build WHERE clause.
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.ID; v != nil {
where, args = append(where, fmt.Sprintf("id = $%d", len(args)+1)), append(args, *v)
}
@@ -441,7 +441,7 @@ func (*Store) findRepositoryImpl(ctx context.Context, tx *Tx, find *api.Reposito
// patchRepositoryImpl updates a repository by ID. Returns the new state of the repository after update.
func (*Store) patchRepositoryImpl(ctx context.Context, tx *Tx, patch *api.RepositoryPatch) (*repositoryRaw, error) {
// Build UPDATE clause.
- set, args := []string{"updater_id = $1"}, []interface{}{patch.UpdaterID}
+ set, args := []string{"updater_id = $1"}, []any{patch.UpdaterID}
if v := patch.BranchFilter; v != nil {
set, args = append(set, fmt.Sprintf("branch_filter = $%d", len(args)+1)), append(args, *v)
}
diff --git a/backend/store/risk.go b/backend/store/risk.go
index 53d80e9127..4f06e694cc 100644
--- a/backend/store/risk.go
+++ b/backend/store/risk.go
@@ -212,7 +212,7 @@ func (s *Store) CreateRisk(ctx context.Context, risk *RiskMessage, creatorID int
// UpdateRisk updates a risk.
func (s *Store) UpdateRisk(ctx context.Context, patch *UpdateRiskMessage, id int64, updaterID int) (*RiskMessage, error) {
- set, args := []string{"updater_id = $1"}, []interface{}{updaterID}
+ set, args := []string{"updater_id = $1"}, []any{updaterID}
if v := patch.Name; v != nil {
set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)
}
diff --git a/backend/store/setting.go b/backend/store/setting.go
index c226ac774a..eac168aec7 100644
--- a/backend/store/setting.go
+++ b/backend/store/setting.go
@@ -176,7 +176,7 @@ func (s *Store) ListSettingV2(ctx context.Context, find *FindSettingMessage) ([]
func (s *Store) UpsertSettingV2(ctx context.Context, update *SetSettingMessage, principalUID int) (*SettingMessage, error) {
fields := []string{"creator_id", "updater_id", "name", "value"}
updateFields := []string{"value = EXCLUDED.value", "updater_id = EXCLUDED.updater_id"}
- valuePlaceholders, args := []string{"$1", "$2", "$3", "$4"}, []interface{}{principalUID, principalUID, update.Name, update.Value}
+ valuePlaceholders, args := []string{"$1", "$2", "$3", "$4"}, []any{principalUID, principalUID, update.Name, update.Value}
if v := update.Description; v != nil {
fields = append(fields, "description")
@@ -238,7 +238,7 @@ func (s *Store) CreateSettingIfNotExistV2(ctx context.Context, create *SettingMe
}
fields := []string{"creator_id", "updater_id", "name", "value", "description"}
- valuesPlaceholders, args := []string{"$1", "$2", "$3", "$4", "$5"}, []interface{}{principalUID, principalUID, create.Name, create.Value, create.Description}
+ valuesPlaceholders, args := []string{"$1", "$2", "$3", "$4", "$5"}, []any{principalUID, principalUID, create.Name, create.Value, create.Description}
query := `INSERT INTO setting (` + strings.Join(fields, ",") + `)
VALUES (` + strings.Join(valuesPlaceholders, ",") + `)
@@ -280,7 +280,7 @@ func (s *Store) DeleteSettingV2(ctx context.Context, name api.SettingName) error
}
func listSettingV2Impl(ctx context.Context, tx *Tx, find *FindSettingMessage) ([]*SettingMessage, error) {
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.Name; v != nil {
where, args = append(where, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)
}
diff --git a/backend/store/sheet.go b/backend/store/sheet.go
index 9d83e812cf..1c92f5b324 100644
--- a/backend/store/sheet.go
+++ b/backend/store/sheet.go
@@ -382,7 +382,7 @@ func createSheetImpl(ctx context.Context, tx *Tx, create *api.SheetCreate) (*she
// patchSheetImpl updates a sheet's name/statement/visibility.
func patchSheetImpl(ctx context.Context, tx *Tx, patch *api.SheetPatch) (*sheetRaw, error) {
- set, args := []string{"updater_id = $1"}, []interface{}{patch.UpdaterID}
+ set, args := []string{"updater_id = $1"}, []any{patch.UpdaterID}
if v := patch.RowStatus; v != nil {
set, args = append(set, fmt.Sprintf("row_status = $%d", len(args)+1)), append(args, api.RowStatus(*v))
}
@@ -446,7 +446,7 @@ func patchSheetImpl(ctx context.Context, tx *Tx, patch *api.SheetPatch) (*sheetR
}
func findSheetImpl(ctx context.Context, tx *Tx, find *api.SheetFind) ([]*sheetRaw, error) {
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.ID; v != nil {
where, args = append(where, fmt.Sprintf("id = $%d", len(args)+1)), append(args, *v)
diff --git a/backend/store/sheet_organizer.go b/backend/store/sheet_organizer.go
index d38055ce40..2ca6fb1fc2 100644
--- a/backend/store/sheet_organizer.go
+++ b/backend/store/sheet_organizer.go
@@ -116,7 +116,7 @@ func upsertSheetOrganizerImpl(ctx context.Context, tx *Tx, upsert *api.SheetOrga
}
func findSheetOrganizerListImpl(ctx context.Context, tx *Tx, find *api.SheetOrganizerFind) ([]*sheetOrganizerRaw, error) {
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
where, args = append(where, fmt.Sprintf("sheet_id = $%d", len(args)+1)), append(args, find.SheetID)
where, args = append(where, fmt.Sprintf("principal_id = $%d", len(args)+1)), append(args, find.PrincipalID)
diff --git a/backend/store/stage.go b/backend/store/stage.go
index b6210d570e..bcfe55a30c 100644
--- a/backend/store/stage.go
+++ b/backend/store/stage.go
@@ -27,7 +27,7 @@ func (s *Store) CreateStageV2(ctx context.Context, stagesCreate []*StageMessage,
defer tx.Rollback()
var valueStr []string
- var values []interface{}
+ var values []any
for i, create := range stagesCreate {
values = append(values,
creatorID,
@@ -84,7 +84,7 @@ func (s *Store) CreateStageV2(ctx context.Context, stagesCreate []*StageMessage,
// ListStageV2 finds a list of stages based on find.
func (s *Store) ListStageV2(ctx context.Context, pipelineUID int) ([]*StageMessage, error) {
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
where, args = append(where, fmt.Sprintf("pipeline_id = $%d", len(args)+1)), append(args, pipelineUID)
tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})
diff --git a/backend/store/stats.go b/backend/store/stats.go
index 8d0b37db0a..1ea1fdded8 100644
--- a/backend/store/stats.go
+++ b/backend/store/stats.go
@@ -18,7 +18,7 @@ type CountInstanceMessage struct {
// CountInstance counts the number of instances.
func (s *Store) CountInstance(ctx context.Context, find *CountInstanceMessage) (int, error) {
- where, args := []string{"instance.row_status = $1"}, []interface{}{api.Normal}
+ where, args := []string{"instance.row_status = $1"}, []any{api.Normal}
if v := find.EnvironmentID; v != nil {
where, args = append(where, fmt.Sprintf("environment.resource_id = $%d", len(args)+1)), append(args, *v)
}
diff --git a/backend/store/task.go b/backend/store/task.go
index 702822628d..dd2ea8139a 100644
--- a/backend/store/task.go
+++ b/backend/store/task.go
@@ -211,7 +211,7 @@ func (s *Store) GetTaskV2ByID(ctx context.Context, id int) (*TaskMessage, error)
// CreateTasksV2 creates a new task.
func (s *Store) CreateTasksV2(ctx context.Context, creates ...*api.TaskCreate) ([]*TaskMessage, error) {
var query strings.Builder
- var values []interface{}
+ var values []any
var queryValues []string
if _, err := query.WriteString(
@@ -310,7 +310,7 @@ func (s *Store) CreateTasksV2(ctx context.Context, creates ...*api.TaskCreate) (
// ListTasks retrieves a list of tasks based on find.
func (s *Store) ListTasks(ctx context.Context, find *api.TaskFind) ([]*TaskMessage, error) {
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.ID; v != nil {
where, args = append(where, fmt.Sprintf("task.id = $%d", len(args)+1)), append(args, *v)
}
@@ -426,7 +426,7 @@ func (s *Store) ListTasks(ctx context.Context, find *api.TaskFind) ([]*TaskMessa
// UpdateTaskV2 updates an existing task.
// Returns ENOTFOUND if task does not exist.
func (s *Store) UpdateTaskV2(ctx context.Context, patch *api.TaskPatch) (*TaskMessage, error) {
- set, args := []string{"updater_id = $1"}, []interface{}{patch.UpdaterID}
+ set, args := []string{"updater_id = $1"}, []any{patch.UpdaterID}
if v := patch.DatabaseID; v != nil {
set, args = append(set, fmt.Sprintf("database_id = $%d", len(args)+1)), append(args, *v)
}
@@ -578,7 +578,7 @@ func (s *Store) UpdateTaskStatusV2(ctx context.Context, patch *api.TaskStatusPat
// Updates the task
// Build UPDATE clause.
- set, args := []string{"updater_id = $1"}, []interface{}{patch.UpdaterID}
+ set, args := []string{"updater_id = $1"}, []any{patch.UpdaterID}
set, args = append(set, "status = $2"), append(args, patch.Status)
var payloadSet []string
if v := patch.Skipped; v != nil {
diff --git a/backend/store/task_check_run.go b/backend/store/task_check_run.go
index 87b63480ce..db6e4ba34c 100644
--- a/backend/store/task_check_run.go
+++ b/backend/store/task_check_run.go
@@ -96,7 +96,7 @@ func (*Store) createTaskCheckRunImpl(ctx context.Context, tx *Tx, creates ...*Ta
return nil
}
var query strings.Builder
- var values []interface{}
+ var values []any
var queryValues []string
if _, err := query.WriteString(
`INSERT INTO task_check_run (
@@ -139,7 +139,7 @@ func (s *Store) PatchTaskCheckRunStatus(ctx context.Context, patch *TaskCheckRun
if patch.Result == "" {
patch.Result = "{}"
}
- set, args := []string{"updater_id = $1"}, []interface{}{patch.UpdaterID}
+ set, args := []string{"updater_id = $1"}, []any{patch.UpdaterID}
set, args = append(set, "status = $2"), append(args, patch.Status)
set, args = append(set, "code = $3"), append(args, patch.Code)
set, args = append(set, "result = $4"), append(args, patch.Result)
@@ -192,7 +192,7 @@ func (s *Store) ListTaskCheckRuns(ctx context.Context, find *TaskCheckRunFind) (
func (*Store) findTaskCheckRunImpl(ctx context.Context, tx *Tx, find *TaskCheckRunFind) ([]*TaskCheckRunMessage, error) {
joinClause := ""
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.TaskID; v != nil {
where, args = append(where, fmt.Sprintf("task_check_run.task_id = $%d", len(args)+1)), append(args, *v)
}
diff --git a/backend/store/task_dag.go b/backend/store/task_dag.go
index f2e02302a1..58b83344ac 100644
--- a/backend/store/task_dag.go
+++ b/backend/store/task_dag.go
@@ -57,7 +57,7 @@ func (s *Store) CreateTaskDAGV2(ctx context.Context, create *TaskDAGMessage) err
// ListTaskDags lists task dags.
func (s *Store) ListTaskDags(ctx context.Context, find *TaskDAGFind) ([]*TaskDAGMessage, error) {
joinClause := ""
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.StageID; v != nil {
where, args = append(where, fmt.Sprintf("task.stage_id = $%d", len(args)+1)), append(args, *v)
}
diff --git a/backend/store/task_run.go b/backend/store/task_run.go
index 89b4fc94eb..0937d95979 100644
--- a/backend/store/task_run.go
+++ b/backend/store/task_run.go
@@ -132,7 +132,7 @@ func (s *Store) getTaskRunTx(ctx context.Context, tx *Tx, find *TaskRunFind) (*T
// patchTaskRunStatusImpl updates a taskRun status. Returns the new state of the taskRun after update.
func (*Store) patchTaskRunStatusImpl(ctx context.Context, tx *Tx, patch *TaskRunStatusPatch) (*TaskRunMessage, error) {
- set, args := []string{"updater_id = $1"}, []interface{}{patch.UpdaterID}
+ set, args := []string{"updater_id = $1"}, []any{patch.UpdaterID}
set, args = append(set, "status = $2"), append(args, patch.Status)
if v := patch.Code; v != nil {
set, args = append(set, fmt.Sprintf("code = $%d", len(args)+1)), append(args, *v)
@@ -209,7 +209,7 @@ func (s *Store) listTaskRun(ctx context.Context, find *TaskRunFind) ([]*TaskRunM
func (*Store) findTaskRunImpl(ctx context.Context, tx *Tx, find *TaskRunFind) ([]*TaskRunMessage, error) {
joinClause := ""
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.TaskID; v != nil {
where, args = append(where, fmt.Sprintf("task_run.task_id = $%d", len(args)+1)), append(args, *v)
}
diff --git a/backend/store/vcs.go b/backend/store/vcs.go
index 5300b1fef8..f29ab7c6fe 100644
--- a/backend/store/vcs.go
+++ b/backend/store/vcs.go
@@ -248,7 +248,7 @@ func createVCSImpl(ctx context.Context, tx *Tx, create *api.VCSCreate) (*vcsRaw,
func findVCSImpl(ctx context.Context, tx *Tx, find *api.VCSFind) ([]*vcsRaw, error) {
// Build WHERE clause.
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.ID; v != nil {
where, args = append(where, "id = $1"), append(args, *v)
}
@@ -299,7 +299,7 @@ func findVCSImpl(ctx context.Context, tx *Tx, find *api.VCSFind) ([]*vcsRaw, err
// patchVCSImpl updates a vcs by ID. Returns the new state of the vcs after update.
func patchVCSImpl(ctx context.Context, tx *Tx, patch *api.VCSPatch) (*vcsRaw, error) {
// Build UPDATE clause.
- set, args := []string{"updater_id = $1"}, []interface{}{patch.UpdaterID}
+ set, args := []string{"updater_id = $1"}, []any{patch.UpdaterID}
if v := patch.Name; v != nil {
set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)
}
@@ -475,7 +475,7 @@ func (s *Store) CreateExternalVersionControlV2(ctx context.Context, principalUID
// UpdateExternalVersionControlV2 updates an external version control.
func (s *Store) UpdateExternalVersionControlV2(ctx context.Context, principalUID int, externalVersionControlUID int, update *UpdateExternalVersionControlMessage) (*ExternalVersionControlMessage, error) {
// Build UPDATE clause.
- set, args := []string{"updater_id = $1"}, []interface{}{principalUID}
+ set, args := []string{"updater_id = $1"}, []any{principalUID}
if v := update.Name; v != nil {
set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)
}
@@ -539,7 +539,7 @@ func (s *Store) DeleteExternalVersionControlV2(ctx context.Context, externalVers
}
func (*Store) findExternalVersionControlsImplV2(ctx context.Context, tx *Tx, find *findExternalVersionControlMessage) ([]*ExternalVersionControlMessage, error) {
- where, args := []string{"TRUE"}, []interface{}{}
+ where, args := []string{"TRUE"}, []any{}
if v := find.id; v != nil {
// Build WHERE clause.
where, args = append(where, fmt.Sprintf("id = $%d", len(args)+1)), append(args, *v)
diff --git a/backend/tests/ghost_test.go b/backend/tests/ghost_test.go
index 42c74486c2..9b69733d94 100644
--- a/backend/tests/ghost_test.go
+++ b/backend/tests/ghost_test.go
@@ -21,6 +21,25 @@ import (
"github.com/stretchr/testify/require"
)
+const (
+ mysqlMigrationStatement = `
+ CREATE TABLE book (
+ id INT PRIMARY KEY AUTO_INCREMENT,
+ name TEXT
+ );
+ `
+ mysqlGhostMigrationStatement = `
+ ALTER TABLE book ADD author VARCHAR(54)
+ `
+ mysqlQueryBookTable = `
+ SELECT * FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE table_name = 'book'
+ ORDER BY ORDINAL_POSITION
+ `
+ mysqlBookSchema1 = `[["TABLE_CATALOG","TABLE_SCHEMA","TABLE_NAME","COLUMN_NAME","ORDINAL_POSITION","COLUMN_DEFAULT","IS_NULLABLE","DATA_TYPE","CHARACTER_MAXIMUM_LENGTH","CHARACTER_OCTET_LENGTH","NUMERIC_PRECISION","NUMERIC_SCALE","DATETIME_PRECISION","CHARACTER_SET_NAME","COLLATION_NAME","COLUMN_TYPE","COLUMN_KEY","EXTRA","PRIVILEGES","COLUMN_COMMENT","GENERATION_EXPRESSION","SRS_ID"],["VARCHAR","VARCHAR","VARCHAR","VARCHAR","UNSIGNED INT","TEXT","VARCHAR","TEXT","BIGINT","BIGINT","UNSIGNED BIGINT","UNSIGNED BIGINT","UNSIGNED INT","VARCHAR","VARCHAR","TEXT","CHAR","VARCHAR","VARCHAR","TEXT","TEXT","UNSIGNED INT"],[["def","testGhostSchemaUpdate","book","id","1",null,"NO","int",null,null,"10","0",null,null,null,"int","PRI","auto_increment","select,insert,update,references","","",null],["def","testGhostSchemaUpdate","book","name","2",null,"YES","text","65535","65535",null,null,null,"utf8mb4","utf8mb4_general_ci","text","","","select,insert,update,references","","",null]],[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]]`
+ mysqlBookSchema2 = `[["TABLE_CATALOG","TABLE_SCHEMA","TABLE_NAME","COLUMN_NAME","ORDINAL_POSITION","COLUMN_DEFAULT","IS_NULLABLE","DATA_TYPE","CHARACTER_MAXIMUM_LENGTH","CHARACTER_OCTET_LENGTH","NUMERIC_PRECISION","NUMERIC_SCALE","DATETIME_PRECISION","CHARACTER_SET_NAME","COLLATION_NAME","COLUMN_TYPE","COLUMN_KEY","EXTRA","PRIVILEGES","COLUMN_COMMENT","GENERATION_EXPRESSION","SRS_ID"],["VARCHAR","VARCHAR","VARCHAR","VARCHAR","UNSIGNED INT","TEXT","VARCHAR","TEXT","BIGINT","BIGINT","UNSIGNED BIGINT","UNSIGNED BIGINT","UNSIGNED INT","VARCHAR","VARCHAR","TEXT","CHAR","VARCHAR","VARCHAR","TEXT","TEXT","UNSIGNED INT"],[["def","testGhostSchemaUpdate","book","id","1",null,"NO","int",null,null,"10","0",null,null,null,"int","PRI","auto_increment","select,insert,update,references","","",null],["def","testGhostSchemaUpdate","book","name","2",null,"YES","text","65535","65535",null,null,null,"utf8mb4","utf8mb4_general_ci","text","","","select,insert,update,references","","",null],["def","testGhostSchemaUpdate","book","author","3",null,"YES","varchar","54","216",null,null,null,"utf8mb4","utf8mb4_general_ci","varchar(54)","","","select,insert,update,references","","",null]],[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]]`
+)
+
func TestGhostParser(t *testing.T) {
t.Parallel()
a := require.New(t)
@@ -45,25 +64,7 @@ func TestGhostParser(t *testing.T) {
}
func TestGhostSchemaUpdate(t *testing.T) {
- const (
- databaseName = "testGhostSchemaUpdate"
- mysqlMigrationStatement = `
- CREATE TABLE book (
- id INT PRIMARY KEY AUTO_INCREMENT,
- name TEXT
- );
- `
- mysqlGhostMigrationStatement = `
- ALTER TABLE book ADD author VARCHAR(54)
- `
- mysqlQueryBookTable = `
- SELECT * FROM INFORMATION_SCHEMA.COLUMNS
- WHERE table_name = 'book'
- ORDER BY ORDINAL_POSITION
- `
- mysqlBookSchema1 = `[["TABLE_CATALOG","TABLE_SCHEMA","TABLE_NAME","COLUMN_NAME","ORDINAL_POSITION","COLUMN_DEFAULT","IS_NULLABLE","DATA_TYPE","CHARACTER_MAXIMUM_LENGTH","CHARACTER_OCTET_LENGTH","NUMERIC_PRECISION","NUMERIC_SCALE","DATETIME_PRECISION","CHARACTER_SET_NAME","COLLATION_NAME","COLUMN_TYPE","COLUMN_KEY","EXTRA","PRIVILEGES","COLUMN_COMMENT","GENERATION_EXPRESSION","SRS_ID"],["VARCHAR","VARCHAR","VARCHAR","VARCHAR","INT","TEXT","VARCHAR","TEXT","BIGINT","BIGINT","BIGINT","BIGINT","INT","VARCHAR","VARCHAR","TEXT","CHAR","VARCHAR","VARCHAR","TEXT","TEXT","INT"],[["def","testGhostSchemaUpdate","book","id",1,null,"NO","int",null,null,"10","0",null,null,null,"int","PRI","auto_increment","select,insert,update,references","","",null],["def","testGhostSchemaUpdate","book","name",2,null,"YES","text","65535","65535",null,null,null,"utf8mb4","utf8mb4_general_ci","text","","","select,insert,update,references","","",null]],[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]]`
- mysqlBookSchema2 = `[["TABLE_CATALOG","TABLE_SCHEMA","TABLE_NAME","COLUMN_NAME","ORDINAL_POSITION","COLUMN_DEFAULT","IS_NULLABLE","DATA_TYPE","CHARACTER_MAXIMUM_LENGTH","CHARACTER_OCTET_LENGTH","NUMERIC_PRECISION","NUMERIC_SCALE","DATETIME_PRECISION","CHARACTER_SET_NAME","COLLATION_NAME","COLUMN_TYPE","COLUMN_KEY","EXTRA","PRIVILEGES","COLUMN_COMMENT","GENERATION_EXPRESSION","SRS_ID"],["VARCHAR","VARCHAR","VARCHAR","VARCHAR","INT","TEXT","VARCHAR","TEXT","BIGINT","BIGINT","BIGINT","BIGINT","INT","VARCHAR","VARCHAR","TEXT","CHAR","VARCHAR","VARCHAR","TEXT","TEXT","INT"],[["def","testGhostSchemaUpdate","book","id",1,null,"NO","int",null,null,"10","0",null,null,null,"int","PRI","auto_increment","select,insert,update,references","","",null],["def","testGhostSchemaUpdate","book","name",2,null,"YES","text","65535","65535",null,null,null,"utf8mb4","utf8mb4_general_ci","text","","","select,insert,update,references","","",null],["def","testGhostSchemaUpdate","book","author",3,null,"YES","varchar","54","216",null,null,null,"utf8mb4","utf8mb4_general_ci","varchar(54)","","","select,insert,update,references","","",null]],[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]]`
- )
+ const databaseName = "testGhostSchemaUpdate"
t.Parallel()
a := require.New(t)
@@ -202,25 +203,8 @@ func TestGhostSchemaUpdate(t *testing.T) {
}
func TestGhostTenant(t *testing.T) {
- var (
- databaseName = "testGhostSchemaUpdate"
- mysqlMigrationStatement = `
- CREATE TABLE book (
- id INT PRIMARY KEY AUTO_INCREMENT,
- name TEXT
- );
- `
- mysqlGhostMigrationStatement = `
- ALTER TABLE book ADD author VARCHAR(54)
- `
- mysqlQueryBookTable = `
- SELECT * FROM INFORMATION_SCHEMA.COLUMNS
- WHERE table_name = 'book'
- ORDER BY ORDINAL_POSITION
- `
- mysqlBookSchema1 = `[["TABLE_CATALOG","TABLE_SCHEMA","TABLE_NAME","COLUMN_NAME","ORDINAL_POSITION","COLUMN_DEFAULT","IS_NULLABLE","DATA_TYPE","CHARACTER_MAXIMUM_LENGTH","CHARACTER_OCTET_LENGTH","NUMERIC_PRECISION","NUMERIC_SCALE","DATETIME_PRECISION","CHARACTER_SET_NAME","COLLATION_NAME","COLUMN_TYPE","COLUMN_KEY","EXTRA","PRIVILEGES","COLUMN_COMMENT","GENERATION_EXPRESSION","SRS_ID"],["VARCHAR","VARCHAR","VARCHAR","VARCHAR","INT","TEXT","VARCHAR","TEXT","BIGINT","BIGINT","BIGINT","BIGINT","INT","VARCHAR","VARCHAR","TEXT","CHAR","VARCHAR","VARCHAR","TEXT","TEXT","INT"],[["def","testGhostSchemaUpdate","book","id",1,null,"NO","int",null,null,"10","0",null,null,null,"int","PRI","auto_increment","select,insert,update,references","","",null],["def","testGhostSchemaUpdate","book","name",2,null,"YES","text","65535","65535",null,null,null,"utf8mb4","utf8mb4_general_ci","text","","","select,insert,update,references","","",null]],[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]]`
- mysqlBookSchema2 = `[["TABLE_CATALOG","TABLE_SCHEMA","TABLE_NAME","COLUMN_NAME","ORDINAL_POSITION","COLUMN_DEFAULT","IS_NULLABLE","DATA_TYPE","CHARACTER_MAXIMUM_LENGTH","CHARACTER_OCTET_LENGTH","NUMERIC_PRECISION","NUMERIC_SCALE","DATETIME_PRECISION","CHARACTER_SET_NAME","COLLATION_NAME","COLUMN_TYPE","COLUMN_KEY","EXTRA","PRIVILEGES","COLUMN_COMMENT","GENERATION_EXPRESSION","SRS_ID"],["VARCHAR","VARCHAR","VARCHAR","VARCHAR","INT","TEXT","VARCHAR","TEXT","BIGINT","BIGINT","BIGINT","BIGINT","INT","VARCHAR","VARCHAR","TEXT","CHAR","VARCHAR","VARCHAR","TEXT","TEXT","INT"],[["def","testGhostSchemaUpdate","book","id",1,null,"NO","int",null,null,"10","0",null,null,null,"int","PRI","auto_increment","select,insert,update,references","","",null],["def","testGhostSchemaUpdate","book","name",2,null,"YES","text","65535","65535",null,null,null,"utf8mb4","utf8mb4_general_ci","text","","","select,insert,update,references","","",null],["def","testGhostSchemaUpdate","book","author",3,null,"YES","varchar","54","216",null,null,null,"utf8mb4","utf8mb4_general_ci","varchar(54)","","","select,insert,update,references","","",null]],[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false]]`
- )
+ const databaseName = "testGhostSchemaUpdate"
+
t.Parallel()
a := require.New(t)
ctx := context.Background()
diff --git a/backend/tests/schema_update_test.go b/backend/tests/schema_update_test.go
index 42ba3ce0b4..3afd2739c2 100644
--- a/backend/tests/schema_update_test.go
+++ b/backend/tests/schema_update_test.go
@@ -282,7 +282,7 @@ func TestVCS(t *testing.T) {
vcsType vcs.Type
externalID string
repositoryFullPath string
- newWebhookPushEvent func(added, modified [][]string, beforeSHA, afterSHA string) interface{}
+ newWebhookPushEvent func(added, modified [][]string, beforeSHA, afterSHA string) any
}{
{
name: "GitLab",
@@ -290,7 +290,7 @@ func TestVCS(t *testing.T) {
vcsType: vcs.GitLab,
externalID: "121",
repositoryFullPath: "test/schemaUpdate",
- newWebhookPushEvent: func(added, modified [][]string, beforeSHA, afterSHA string) interface{} {
+ newWebhookPushEvent: func(added, modified [][]string, beforeSHA, afterSHA string) any {
var commitList []gitlab.WebhookCommit
for i := range added {
commitList = append(commitList, gitlab.WebhookCommit{
@@ -317,7 +317,7 @@ func TestVCS(t *testing.T) {
vcsType: vcs.GitHub,
externalID: "octocat/Hello-World",
repositoryFullPath: "octocat/Hello-World",
- newWebhookPushEvent: func(added, modified [][]string, beforeSHA, afterSHA string) interface{} {
+ newWebhookPushEvent: func(added, modified [][]string, beforeSHA, afterSHA string) any {
var commits []github.WebhookCommit
for i := range added {
commits = append(commits, github.WebhookCommit{
@@ -356,7 +356,7 @@ func TestVCS(t *testing.T) {
vcsType: vcs.Bitbucket,
externalID: "octocat/Hello-World",
repositoryFullPath: "octocat/Hello-World",
- newWebhookPushEvent: func(added, _ [][]string, beforeSHA, afterSHA string) interface{} {
+ newWebhookPushEvent: func(added, _ [][]string, beforeSHA, afterSHA string) any {
var commits []bitbucket.WebhookCommit
for range added {
commits = append(commits, bitbucket.WebhookCommit{
@@ -760,7 +760,7 @@ func TestVCS_SDL(t *testing.T) {
vcsType vcs.Type
externalID string
repositoryFullPath string
- newWebhookPushEvent func(added, modified []string, beforeSHA, afterSHA string) interface{}
+ newWebhookPushEvent func(added, modified []string, beforeSHA, afterSHA string) any
}{
{
name: "GitLab",
@@ -768,7 +768,7 @@ func TestVCS_SDL(t *testing.T) {
vcsType: vcs.GitLab,
externalID: "121",
repositoryFullPath: "test/schemaUpdate",
- newWebhookPushEvent: func(added, modified []string, beforeSHA, afterSHA string) interface{} {
+ newWebhookPushEvent: func(added, modified []string, beforeSHA, afterSHA string) any {
return gitlab.WebhookPushEvent{
ObjectKind: gitlab.WebhookPush,
Ref: "refs/heads/feature/foo",
@@ -793,7 +793,7 @@ func TestVCS_SDL(t *testing.T) {
vcsType: vcs.GitHub,
externalID: "octocat/Hello-World",
repositoryFullPath: "octocat/Hello-World",
- newWebhookPushEvent: func(added, modified []string, beforeSHA, afterSHA string) interface{} {
+ newWebhookPushEvent: func(added, modified []string, beforeSHA, afterSHA string) any {
return github.WebhookPushEvent{
Ref: "refs/heads/feature/foo",
Before: beforeSHA,
@@ -1147,7 +1147,7 @@ func TestWildcardInVCSFilePathTemplate(t *testing.T) {
externalID := "121"
repoFullPath := "test/wildcard"
- defaultNewWebhookPushEvent := func(added []string, beforeSHA, afterSHA string) interface{} {
+ defaultNewWebhookPushEvent := func(added []string, beforeSHA, afterSHA string) any {
return gitlab.WebhookPushEvent{
ObjectKind: gitlab.WebhookPush,
Ref: fmt.Sprintf("refs/heads/%s", branchFilter),
@@ -1174,7 +1174,7 @@ func TestWildcardInVCSFilePathTemplate(t *testing.T) {
commitNewFileNames []string
commitNewFileContents []string
expect []bool
- newWebhookPushEvent func(added []string, beforeSHA, afterSHA string) interface{}
+ newWebhookPushEvent func(added []string, beforeSHA, afterSHA string) any
}{
{
name: "singleAsterisk",
@@ -2324,7 +2324,7 @@ func TestVCS_SDL_MySQL(t *testing.T) {
vcsType vcs.Type
externalID string
repositoryFullPath string
- newWebhookPushEvent func(added, modified []string, beforeSHA, afterSHA string) interface{}
+ newWebhookPushEvent func(added, modified []string, beforeSHA, afterSHA string) any
}{
{
name: "GitLab",
@@ -2332,7 +2332,7 @@ func TestVCS_SDL_MySQL(t *testing.T) {
vcsType: vcs.GitLab,
externalID: "121",
repositoryFullPath: "test/schemaUpdate",
- newWebhookPushEvent: func(added, modified []string, beforeSHA, afterSHA string) interface{} {
+ newWebhookPushEvent: func(added, modified []string, beforeSHA, afterSHA string) any {
return gitlab.WebhookPushEvent{
ObjectKind: gitlab.WebhookPush,
Ref: "refs/heads/feature/foo",
@@ -2357,7 +2357,7 @@ func TestVCS_SDL_MySQL(t *testing.T) {
vcsType: vcs.GitHub,
externalID: "octocat/Hello-World",
repositoryFullPath: "octocat/Hello-World",
- newWebhookPushEvent: func(added, modified []string, beforeSHA, afterSHA string) interface{} {
+ newWebhookPushEvent: func(added, modified []string, beforeSHA, afterSHA string) any {
return github.WebhookPushEvent{
Ref: "refs/heads/feature/foo",
Before: beforeSHA,
diff --git a/backend/tests/start_test.go b/backend/tests/start_test.go
index be7d14d1a5..7239aa87c3 100644
--- a/backend/tests/start_test.go
+++ b/backend/tests/start_test.go
@@ -57,10 +57,10 @@ func TestServerRestart(t *testing.T) {
a.NoError(err)
// Start server in readonly mode
- startStopServer(ctx, a, ctl, dataDir, true /*readOnly*/)
+ startStopServer(ctx, a, ctl, dataDir, true /* readOnly */)
// Start server in non-readonly mode
- startStopServer(ctx, a, ctl, dataDir, false /*readOnly*/)
+ startStopServer(ctx, a, ctl, dataDir, false /* readOnly */)
}
var (
diff --git a/backend/tests/tenant_test.go b/backend/tests/tenant_test.go
index a811983a0c..1cf9ff2762 100644
--- a/backend/tests/tenant_test.go
+++ b/backend/tests/tenant_test.go
@@ -207,7 +207,7 @@ func TestTenantVCS(t *testing.T) {
vcsType vcs.Type
externalID string
repositoryFullPath string
- newWebhookPushEvent func(gitFile, beforeSHA, afterSHA string) interface{}
+ newWebhookPushEvent func(gitFile, beforeSHA, afterSHA string) any
}{
{
name: "GitLab",
@@ -215,7 +215,7 @@ func TestTenantVCS(t *testing.T) {
vcsType: vcs.GitLab,
externalID: "121",
repositoryFullPath: "test/schemaUpdate",
- newWebhookPushEvent: func(gitFile, beforeSHA, afterSHA string) interface{} {
+ newWebhookPushEvent: func(gitFile, beforeSHA, afterSHA string) any {
return gitlab.WebhookPushEvent{
ObjectKind: gitlab.WebhookPush,
Ref: "refs/heads/feature/foo",
@@ -239,7 +239,7 @@ func TestTenantVCS(t *testing.T) {
vcsType: vcs.GitHub,
externalID: "octocat/Hello-World",
repositoryFullPath: "octocat/Hello-World",
- newWebhookPushEvent: func(gitFile, beforeSHA, afterSHA string) interface{} {
+ newWebhookPushEvent: func(gitFile, beforeSHA, afterSHA string) any {
return github.WebhookPushEvent{
Ref: "refs/heads/feature/foo",
Before: beforeSHA,
@@ -653,7 +653,7 @@ func TestTenantVCSDatabaseNameTemplate(t *testing.T) {
vcsType vcs.Type
externalID string
repositoryFullPath string
- newWebhookPushEvent func(gitFile, beforeSHA, afterSHA string) interface{}
+ newWebhookPushEvent func(gitFile, beforeSHA, afterSHA string) any
}{
{
name: "GitLab",
@@ -661,7 +661,7 @@ func TestTenantVCSDatabaseNameTemplate(t *testing.T) {
vcsType: vcs.GitLab,
externalID: "121",
repositoryFullPath: "test/schemaUpdate",
- newWebhookPushEvent: func(gitFile, beforeSHA, afterSHA string) interface{} {
+ newWebhookPushEvent: func(gitFile, beforeSHA, afterSHA string) any {
return gitlab.WebhookPushEvent{
ObjectKind: gitlab.WebhookPush,
Ref: "refs/heads/feature/foo",
@@ -685,7 +685,7 @@ func TestTenantVCSDatabaseNameTemplate(t *testing.T) {
vcsType: vcs.GitHub,
externalID: "octocat/Hello-World",
repositoryFullPath: "octocat/Hello-World",
- newWebhookPushEvent: func(gitFile, beforeSHA, afterSHA string) interface{} {
+ newWebhookPushEvent: func(gitFile, beforeSHA, afterSHA string) any {
return github.WebhookPushEvent{
Ref: "refs/heads/feature/foo",
Before: beforeSHA,
@@ -983,7 +983,7 @@ func TestTenantVCSDatabaseNameTemplate_Empty(t *testing.T) {
vcsType vcs.Type
externalID string
repositoryFullPath string
- newWebhookPushEvent func(gitFile, beforeSHA, afterSHA string) interface{}
+ newWebhookPushEvent func(gitFile, beforeSHA, afterSHA string) any
}{
{
name: "GitLab",
@@ -991,7 +991,7 @@ func TestTenantVCSDatabaseNameTemplate_Empty(t *testing.T) {
vcsType: vcs.GitLab,
externalID: "121",
repositoryFullPath: "test/schemaUpdate",
- newWebhookPushEvent: func(gitFile, beforeSHA, afterSHA string) interface{} {
+ newWebhookPushEvent: func(gitFile, beforeSHA, afterSHA string) any {
return gitlab.WebhookPushEvent{
ObjectKind: gitlab.WebhookPush,
Ref: "refs/heads/feature/foo",
@@ -1015,7 +1015,7 @@ func TestTenantVCSDatabaseNameTemplate_Empty(t *testing.T) {
vcsType: vcs.GitHub,
externalID: "octocat/Hello-World",
repositoryFullPath: "octocat/Hello-World",
- newWebhookPushEvent: func(gitFile, beforeSHA, afterSHA string) interface{} {
+ newWebhookPushEvent: func(gitFile, beforeSHA, afterSHA string) any {
return github.WebhookPushEvent{
Ref: "refs/heads/feature/foo",
Before: beforeSHA,
@@ -1264,7 +1264,7 @@ func TestTenantVCS_YAML(t *testing.T) {
vcsType vcs.Type
externalID string
repositoryFullPath string
- newWebhookPushEvent func(gitFile, beforeSHA, afterSHA string) interface{}
+ newWebhookPushEvent func(gitFile, beforeSHA, afterSHA string) any
}{
{
name: "GitLab",
@@ -1272,7 +1272,7 @@ func TestTenantVCS_YAML(t *testing.T) {
vcsType: vcs.GitLab,
externalID: "121",
repositoryFullPath: "test/dataUpdate",
- newWebhookPushEvent: func(gitFile, beforeSHA, afterSHA string) interface{} {
+ newWebhookPushEvent: func(gitFile, beforeSHA, afterSHA string) any {
return gitlab.WebhookPushEvent{
ObjectKind: gitlab.WebhookPush,
Ref: "refs/heads/feature/foo",
@@ -1296,7 +1296,7 @@ func TestTenantVCS_YAML(t *testing.T) {
vcsType: vcs.GitHub,
externalID: "octocat/Hello-World",
repositoryFullPath: "octocat/Hello-World",
- newWebhookPushEvent: func(gitFile, beforeSHA, afterSHA string) interface{} {
+ newWebhookPushEvent: func(gitFile, beforeSHA, afterSHA string) any {
return github.WebhookPushEvent{
Ref: "refs/heads/feature/foo",
Before: beforeSHA,
diff --git a/backend/tests/test-data/sql_review_mysql.yaml b/backend/tests/test-data/sql_review_mysql.yaml
index 96d31429ac..62e4c5124f 100644
--- a/backend/tests/test-data/sql_review_mysql.yaml
+++ b/backend/tests/test-data/sql_review_mysql.yaml
@@ -220,13 +220,13 @@
code: 209
status: WARN
title: statement.affected-row-limit
- content: '"DELETE FROM tech_book" dry runs failed: Error 1146: Table ''testsqlreview.tech_book'' doesn''t exist'
+ content: '"DELETE FROM tech_book" dry runs failed: Error 1146 (42S02): Table ''testsqlreview.tech_book'' doesn''t exist'
line: 1
- namespace: bb.advisor
code: 208
status: ERROR
title: statement.dml-dry-run
- content: '"DELETE FROM tech_book" dry runs failed: Error 1146: Table ''testsqlreview.tech_book'' doesn''t exist'
+ content: '"DELETE FROM tech_book" dry runs failed: Error 1146 (42S02): Table ''testsqlreview.tech_book'' doesn''t exist'
line: 1
run: false
- statement: DELETE FROM tech_book WHERE name like `%abc`
@@ -241,13 +241,13 @@
code: 209
status: WARN
title: statement.affected-row-limit
- content: '"DELETE FROM tech_book WHERE name like `%abc`" dry runs failed: Error 1146: Table ''testsqlreview.tech_book'' doesn''t exist'
+ content: '"DELETE FROM tech_book WHERE name like `%abc`" dry runs failed: Error 1146 (42S02): Table ''testsqlreview.tech_book'' doesn''t exist'
line: 1
- namespace: bb.advisor
code: 208
status: ERROR
title: statement.dml-dry-run
- content: '"DELETE FROM tech_book WHERE name like `%abc`" dry runs failed: Error 1146: Table ''testsqlreview.tech_book'' doesn''t exist'
+ content: '"DELETE FROM tech_book WHERE name like `%abc`" dry runs failed: Error 1146 (42S02): Table ''testsqlreview.tech_book'' doesn''t exist'
line: 1
run: false
- statement: ' INSERT INTO t_copy SELECT * FROM t'
@@ -268,7 +268,7 @@
code: 1101
status: WARN
title: statement.insert.row-limit
- content: '"INSERT INTO t_copy SELECT * FROM t" dry runs failed: Error 1146: Table ''testsqlreview.t_copy'' doesn''t exist'
+ content: '"INSERT INTO t_copy SELECT * FROM t" dry runs failed: Error 1146 (42S02): Table ''testsqlreview.t_copy'' doesn''t exist'
line: 1
- namespace: bb.advisor
code: 1107
@@ -280,7 +280,7 @@
code: 208
status: ERROR
title: statement.dml-dry-run
- content: '"INSERT INTO t_copy SELECT * FROM t" dry runs failed: Error 1146: Table ''testsqlreview.t_copy'' doesn''t exist'
+ content: '"INSERT INTO t_copy SELECT * FROM t" dry runs failed: Error 1146 (42S02): Table ''testsqlreview.t_copy'' doesn''t exist'
line: 1
run: false
- statement: ' INSERT INTO t VALUES (1, 1, now(), 1, now())'
@@ -295,7 +295,7 @@
code: 208
status: ERROR
title: statement.dml-dry-run
- content: '"INSERT INTO t VALUES (1, 1, now(), 1, now())" dry runs failed: Error 1146: Table ''testsqlreview.t'' doesn''t exist'
+ content: '"INSERT INTO t VALUES (1, 1, now(), 1, now())" dry runs failed: Error 1146 (42S02): Table ''testsqlreview.t'' doesn''t exist'
line: 1
run: false
- statement: DELETE FROM tech_book WHERE id = (SELECT max(id) FROM tech_book WHERE name = 'bytebase')
@@ -304,13 +304,13 @@
code: 209
status: WARN
title: statement.affected-row-limit
- content: '"DELETE FROM tech_book WHERE id = (SELECT max(id) FROM tech_book WHERE name = ''bytebase'')" dry runs failed: Error 1146: Table ''testsqlreview.tech_book'' doesn''t exist'
+ content: '"DELETE FROM tech_book WHERE id = (SELECT max(id) FROM tech_book WHERE name = ''bytebase'')" dry runs failed: Error 1146 (42S02): Table ''testsqlreview.tech_book'' doesn''t exist'
line: 1
- namespace: bb.advisor
code: 208
status: ERROR
title: statement.dml-dry-run
- content: '"DELETE FROM tech_book WHERE id = (SELECT max(id) FROM tech_book WHERE name = ''bytebase'')" dry runs failed: Error 1146: Table ''testsqlreview.tech_book'' doesn''t exist'
+ content: '"DELETE FROM tech_book WHERE id = (SELECT max(id) FROM tech_book WHERE name = ''bytebase'')" dry runs failed: Error 1146 (42S02): Table ''testsqlreview.tech_book'' doesn''t exist'
line: 1
run: false
- statement: COMMIT;
diff --git a/go.mod b/go.mod
index b274d71ec0..61a886127c 100644
--- a/go.mod
+++ b/go.mod
@@ -31,7 +31,7 @@ require (
github.com/labstack/echo/v4 v4.10.2
github.com/lestrrat-go/jwx/v2 v2.0.9
github.com/lib/pq v1.10.7
- github.com/mattn/go-sqlite3 v2.0.3+incompatible
+ github.com/mattn/go-sqlite3 v1.14.16
github.com/microsoft/go-mssqldb v0.21.0
github.com/paulmach/orb v0.9.0
github.com/pganalyze/pg_query_go/v2 v2.1.2
diff --git a/go.sum b/go.sum
index b7d8ea08fd..862ee06ca9 100644
--- a/go.sum
+++ b/go.sum
@@ -612,8 +612,6 @@ github.com/mattn/go-runewidth v0.0.12 h1:Y41i/hVW3Pgwr8gV+J23B9YEY0zxjptBuCWEaxm
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
-github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
-github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=