Skip to content

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

Use %q for quoted literal

天舟819677d24644
diff --git a/db/mysql.go b/db/mysql.go
index 60989e36d3..87ce3575d8 100644
--- a/db/mysql.go
+++ b/db/mysql.go
@@ -461,7 +461,7 @@ func (driver *MySQLDriver) ExecuteMigration(ctx context.Context, m *MigrationInf
return err
}
if duplicate {
- return fmt.Errorf("database '%s' has already applied version %s", m.Database, m.Version)
+ return fmt.Errorf("database %q has already applied version %s", m.Database, m.Version)
}
// Check if there is any higher version already been applied
@@ -470,7 +470,7 @@ func (driver *MySQLDriver) ExecuteMigration(ctx context.Context, m *MigrationInf
return err
}
if version != nil {
- return fmt.Errorf("database '%s' has already applied version %s which is higher than %s", m.Database, *version, m.Version)
+ return fmt.Errorf("database %q has already applied version %s which is higher than %s", m.Database, *version, m.Version)
}
// If the migration engine is VCS and type is not baseline, then we can only proceed if there is existing baseline
@@ -717,7 +717,7 @@ func findNextSequence(ctx context.Context, tx *sql.Tx, namespace string, require
}
// This should not happen normally since we already check the baselining exist beforehand. Just in case.
- return -1, fmt.Errorf("unable to generate next migration_sequence, no migration hisotry found for '%s', do you forget to baselining?", namespace)
+ return -1, fmt.Errorf("unable to generate next migration_sequence, no migration hisotry found for %q, do you forget to baselining?", namespace)
}
return int(sequence.Int32), nil
diff --git a/server/jwt.go b/server/jwt.go
index 162027dabc..715a6971ef 100644
--- a/server/jwt.go
+++ b/server/jwt.go
@@ -188,7 +188,7 @@ func JWTMiddleware(l *zap.Logger, p api.PrincipalService, next echo.HandlerFunc,
if claims.Audience != fmt.Sprintf(accessTokenAudienceFmt, mode) {
return echo.NewHTTPError(http.StatusUnauthorized,
- fmt.Sprintf("Invalid access token, audience mismatch, got '%v', expected '%v'. you may send request to the wrong environment",
+ fmt.Sprintf("Invalid access token, audience mismatch, got %q, expected %q. you may send request to the wrong environment",
claims.Audience,
fmt.Sprintf(accessTokenAudienceFmt, mode),
))
@@ -257,7 +257,7 @@ func JWTMiddleware(l *zap.Logger, p api.PrincipalService, next echo.HandlerFunc,
if refreshTokenClaims.Audience != fmt.Sprintf(refreshTokenAudienceFmt, mode) {
return echo.NewHTTPError(http.StatusUnauthorized,
- fmt.Sprintf("Invalid refresh token, audience mismatch, got '%v', expected '%v'. you may send request to the wrong environment",
+ fmt.Sprintf("Invalid refresh token, audience mismatch, got %q, expected %q. you may send request to the wrong environment",
refreshTokenClaims.Audience,
fmt.Sprintf(refreshTokenAudienceFmt, mode),
))
diff --git a/server/project_webhook.go b/server/project_webhook.go
index 089f4a8f7c..f1cd261d4d 100644
--- a/server/project_webhook.go
+++ b/server/project_webhook.go
@@ -216,7 +216,7 @@ func (s *Server) registerProjectWebhookRoutes(g *echo.Group) {
webhook.WebhookContext{
URL: hook.URL,
Level: webhook.WebhookInfo,
- Title: fmt.Sprintf("Test webhook '%s'", hook.Name),
+ Title: fmt.Sprintf("Test webhook %q", hook.Name),
Description: "This is a test",
Link: fmt.Sprintf("%s:%d/project/%s/webhook/%s", s.frontendHost, s.frontendPort, api.ProjectSlug(project), api.ProjectWebhookSlug(hook)),
CreatorName: "Bytebase",
diff --git a/server/sql.go b/server/sql.go
index 76b60d7622..ca5f6edbd7 100644
--- a/server/sql.go
+++ b/server/sql.go
@@ -55,7 +55,7 @@ func (s *Server) registerSqlRoutes(g *echo.Group) {
if connectionInfo.Port != "" {
hostPort += ":" + connectionInfo.Port
}
- resultSet.Error = fmt.Errorf("failed to connect '%s' for user '%s' (using password: %s), %w", hostPort, connectionInfo.Username, usePassword, err).Error()
+ resultSet.Error = fmt.Errorf("failed to connect %q for user %q (using password: %s), %w", hostPort, connectionInfo.Username, usePassword, err).Error()
} else {
defer db.Close(context.Background())
if err := db.Ping(context.Background()); err != nil {
diff --git a/server/task_executor_database_backup.go b/server/task_executor_database_backup.go
index 9ad36cc540..0430599a13 100644
--- a/server/task_executor_database_backup.go
+++ b/server/task_executor_database_backup.go
@@ -77,7 +77,7 @@ func (exec *DatabaseBackupTaskExecutor) RunOnce(ctx context.Context, server *Ser
return true, "", backupErr
}
- return true, fmt.Sprintf("Backup database '%s'", task.Database.Name), nil
+ return true, fmt.Sprintf("Backup database %q", task.Database.Name), nil
}
// backupDatabase will take a backup of a database.
diff --git a/server/task_executor_database_create.go b/server/task_executor_database_create.go
index 255fe4106b..ba142e2b86 100644
--- a/server/task_executor_database_create.go
+++ b/server/task_executor_database_create.go
@@ -73,5 +73,5 @@ func (exec *DatabaseCreateTaskExecutor) RunOnce(ctx context.Context, server *Ser
return true, "", err
}
- return true, fmt.Sprintf("Created database '%s'", payload.DatabaseName), nil
+ return true, fmt.Sprintf("Created database %q", payload.DatabaseName), nil
}
diff --git a/server/task_executor_schema_update.go b/server/task_executor_schema_update.go
index be2686af92..66cb27333c 100644
--- a/server/task_executor_schema_update.go
+++ b/server/task_executor_schema_update.go
@@ -152,9 +152,9 @@ func (exec *SchemaUpdateTaskExecutor) RunOnce(ctx context.Context, server *Serve
return true, "", err
}
- detail = fmt.Sprintf("Applied migration version %s to database '%s'", mi.Version, databaseName)
+ detail = fmt.Sprintf("Applied migration version %s to database %q", mi.Version, databaseName)
if mi.Type == db.Baseline {
- detail = fmt.Sprintf("Established baseline version %s for database '%s'", mi.Version, databaseName)
+ detail = fmt.Sprintf("Established baseline version %s for database %q", mi.Version, databaseName)
}
return true, detail, nil
diff --git a/server/webhook.go b/server/webhook.go
index 340d27e4b7..89cd1c82b6 100644
--- a/server/webhook.go
+++ b/server/webhook.go
@@ -240,7 +240,7 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {
zap.String("file", added))
continue
}
- createdMessageList = append(createdMessageList, fmt.Sprintf("Created issue '%s' on adding %s", issue.Name, added))
+ createdMessageList = append(createdMessageList, fmt.Sprintf("Created issue %q on adding %s", issue.Name, added))
}
}
}