MCPcopy Index your code
hub / github.com/cloudspannerecosystem/spanner-cli / buildCommands

Function buildCommands

cli.go:499–532  ·  view source on GitHub ↗
(input string)

Source from the content-addressed store, hash-verified

497}
498
499func buildCommands(input string) ([]*command, error) {
500 var cmds []*command
501 var pendingDdls []string
502 for _, separated := range separateInput(input) {
503 // Ignore the last empty statement
504 if separated.delim == delimiterUndefined && separated.statementWithoutComments == "" {
505 continue
506 }
507
508 stmt, err := BuildStatementWithComments(separated.statementWithoutComments, separated.statement)
509 if err != nil {
510 return nil, err
511 }
512 if ddl, ok := stmt.(*DdlStatement); ok {
513 pendingDdls = append(pendingDdls, ddl.Ddl)
514 continue
515 }
516
517 // Flush pending DDLs
518 if len(pendingDdls) > 0 {
519 cmds = append(cmds, &command{&BulkDdlStatement{pendingDdls}, false})
520 pendingDdls = nil
521 }
522
523 cmds = append(cmds, &command{stmt, separated.delim == delimiterVertical})
524 }
525
526 // Flush pending DDLs
527 if len(pendingDdls) > 0 {
528 cmds = append(cmds, &command{&BulkDdlStatement{pendingDdls}, false})
529 }
530
531 return cmds, nil
532}
533
534func confirm(out io.Writer, msg string) bool {
535 fmt.Fprintf(out, "%s [yes/no] ", msg)

Callers 2

RunBatchMethod · 0.85
TestBuildCommandsFunction · 0.85

Calls 2

separateInputFunction · 0.85

Tested by 1

TestBuildCommandsFunction · 0.68