MCPcopy Create free account
hub / github.com/bytebase/bytebase / ParseMongoShell

Function ParseMongoShell

backend/plugin/parser/mongodb/mongodb.go:46–52  ·  view source on GitHub ↗

ParseMongoShell parses a MongoDB shell script and returns parsed statements with their ASTs. Conforms to the standard ParseStatementsFunc interface. The omni parser recovers from syntax errors by skipping to the next statement boundary. When at least one statement parses successfully, this function

(statement string)

Source from the content-addressed store, hash-verified

44// returns the partial results with a nil error. A non-nil error is returned
45// only when no statements could be parsed at all.
46func ParseMongoShell(statement string) ([]base.ParsedStatement, error) {
47 stmts, err := mongo.Parse(statement)
48 if err != nil {
49 return nil, err
50 }
51 return convertStatements(statement, stmts), nil
52}
53
54// ParseMongoShellBestEffort parses a MongoDB shell script and returns as many
55// successfully parsed statements as possible, along with any parse errors.

Callers 5

GetQueryTypeFunction · 0.85
AnalyzeMaskingStatementFunction · 0.85
TestParseMongoShellFunction · 0.85
SplitSQLFunction · 0.85

Calls 1

convertStatementsFunction · 0.85

Tested by 2

TestParseMongoShellFunction · 0.68