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: mongodb format (#11667)
Danny Xua5bcdb46c6aa
diff --git a/backend/plugin/db/mongodb/mongodb.go b/backend/plugin/db/mongodb/mongodb.goindex 9c409f1649..68408bc852 100644--- a/backend/plugin/db/mongodb/mongodb.go+++ b/backend/plugin/db/mongodb/mongodb.go@@ -204,18 +204,13 @@ func (driver *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement stri// 1. Query always short, so it's safe to execute in the command line.// 2. We cannot catch the output if we use the --file option.- // When you see here, it's probable that your mongosh output has been truncated. Errrrrh!- // It appears that the truncation occurs specifically within a Linux container, while everything functions as expected on MacOS.- // This might be due to the surprising Javascript async behavior or unflushed buffer.- // We put a sleep(0) for the eval() to wait for its completion.- // In some cases, the sleep(0) would not work properly, try to let shell to take the responsibility of read from pipe, this is the reason we call sh -c.evalArg := statementif simpleStatement {limit := ""if 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);}`, statement, limit)+ evalArg = fmt.Sprintf(`a = %s; if (typeof a.toArray === 'function') {print(EJSON.stringify(a.toArray()%s));} else {print(EJSON.stringify(a));}`, statement, limit)}// We will use single quotes for the evalArg, so we need to escape the single quotes in the statement.evalArg = strings.ReplaceAll(evalArg, `'`, `'"'`)@@ -295,7 +290,7 @@ func (driver *Driver) QueryConn(ctx context.Context, _ *sql.Conn, statement striColumnTypeNames: []string{"TEXT"},Rows: []*v1pb.QueryRow{{Values: []*v1pb.RowValue{{- Kind: &v1pb.RowValue_StringValue{StringValue: outContent.String()},+ Kind: &v1pb.RowValue_StringValue{StringValue: string(content)},}},}},Latency: durationpb.New(time.Since(startTime)),@@ -442,5 +437,8 @@ func (driver *Driver) RunStatement(ctx context.Context, _ *sql.Conn, statement sfunc isMongoStatement(statement string) bool {statement = strings.ToLower(statement)- return strings.HasPrefix(statement, "db.")+ if strings.HasPrefix(statement, "db.") {+ return true+ }+ return strings.HasPrefix(statement, `db["`)}