Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: using trim instead of trimRight for MongoDB statement (#9809)
h3n4l60e170521c37
diff --git a/backend/plugin/db/mongodb/mongodb.go b/backend/plugin/db/mongodb/mongodb.goindex dc75ffd847..dcc1ba57d5 100644--- a/backend/plugin/db/mongodb/mongodb.go+++ b/backend/plugin/db/mongodb/mongodb.go@@ -191,7 +191,7 @@ func (driver *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement striif queryContext != nil && queryContext.Limit > 0 {limit = fmt.Sprintf(".slice(0, %d)", queryContext.Limit)}- evalArg = fmt.Sprintf(`a = %s; if (typeof a.toArray === 'function') {print(EJSON.stringify(a.toArray()%s)); sleep(0);} else {print(EJSON.stringify(a)); sleep(0);}`, strings.TrimRight(statement, " \t\n\r\f;"), limit)+ evalArg = fmt.Sprintf(`a = %s; if (typeof a.toArray === 'function') {print(EJSON.stringify(a.toArray()%s)); sleep(0);} else {print(EJSON.stringify(a)); sleep(0);}`, strings.Trim(statement, " \t\n\r\f;"), limit)}// We will use single quotes for the evalArg, so we need to escape the single quotes in the statement.evalArg = strings.ReplaceAll(evalArg, `'`, `'"'`)