Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: fix get mysql pringerprint for comments (#5932)
rebelicee667d5b57c89
diff --git a/backend/plugin/parser/sql/utils.go b/backend/plugin/parser/sql/utils.goindex b0c380e93d..181fba2154 100644--- a/backend/plugin/parser/sql/utils.go+++ b/backend/plugin/parser/sql/utils.go@@ -60,7 +60,7 @@ func getMySQLFingerprint(query string) (string, error) {// Match multi-line comments and single-line comments, and remove them.mlcRe := regexp.MustCompile(`(?s)/\*.*?\*/`)- olcRe := regexp.MustCompile(`--.*$`)+ olcRe := regexp.MustCompile(`(?m)--.*$`)query = mlcRe.ReplaceAllString(query, "")query = olcRe.ReplaceAllString(query, "")diff --git a/backend/plugin/parser/sql/utils_test.go b/backend/plugin/parser/sql/utils_test.goindex 75173e2bdc..0a5220a57d 100644--- a/backend/plugin/parser/sql/utils_test.go+++ b/backend/plugin/parser/sql/utils_test.go@@ -221,6 +221,10 @@ func TestGetMySQLFingerprint(t *testing.T) {stmt stringwant string}{+ {+ stmt: "-- this is comment\nSELECT * FROM `mytable`",+ want: "select * from `mytable`",+ },// Test mysqldump query.{stmt: "SELECT /*!40001 SQL_NO_CACHE */ * FROM `mytable`",