Skip to content

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

fix: encode statement (#7033)

boojackaf6a592e4ed3
diff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.go
index aa1592c4ed..61b5271a52 100644
--- a/backend/api/v1/sql_service.go
+++ b/backend/api/v1/sql_service.go
@@ -8,7 +8,6 @@ import (
"encoding/json"
"fmt"
"io"
- "net/url"
"reflect"
"strconv"
"strings"
@@ -2071,7 +2070,6 @@ func IsSQLReviewSupported(dbType db.Type) bool {
// encodeToBase64String encodes the statement to base64 string.
func encodeToBase64String(statement string) string {
- encodedURI := url.QueryEscape(statement)
- base64Encoded := base64.StdEncoding.EncodeToString([]byte(encodedURI))
+ base64Encoded := base64.StdEncoding.EncodeToString([]byte(statement))
return base64Encoded
}
diff --git a/backend/api/v1/sql_service_test.go b/backend/api/v1/sql_service_test.go
index 6e4081ccc0..1683a032e5 100644
--- a/backend/api/v1/sql_service_test.go
+++ b/backend/api/v1/sql_service_test.go
@@ -188,3 +188,34 @@ func TestExportSQL(t *testing.T) {
a.Equal(test.want, string(got))
}
}
+
+func TestEncodeToBase64String(t *testing.T) {
+ tests := []struct {
+ input string
+ want string
+ }{
+ {
+ input: "",
+ want: "",
+ },
+ {
+ input: "select * from employee",
+ want: "c2VsZWN0ICogZnJvbSBlbXBsb3llZQ==",
+ },
+ {
+ input: "select name as 姓名 from employee",
+ want: "c2VsZWN0IG5hbWUgYXMg5aeT5ZCNIGZyb20gZW1wbG95ZWU=",
+ },
+ {
+ input: "Hello 哈喽 👋",
+ want: "SGVsbG8g5ZOI5Za9IPCfkYs=",
+ },
+ }
+
+ for _, test := range tests {
+ got := encodeToBase64String(test.input)
+ if got != test.want {
+ t.Errorf("encodeToBase64String(%q) = %q, want %q", test.input, got, test.want)
+ }
+ }
+}