SplitSQL splits the given SQL statement into individual statements. CosmosDB only supports single SELECT statements.
(statement string)
| 16 | // SplitSQL splits the given SQL statement into individual statements. |
| 17 | // CosmosDB only supports single SELECT statements. |
| 18 | func SplitSQL(statement string) ([]base.Statement, error) { |
| 19 | if strings.TrimSpace(statement) == "" { |
| 20 | return nil, nil |
| 21 | } |
| 22 | |
| 23 | stmts, err := omnicosmosdb.Parse(statement) |
| 24 | if err != nil { |
| 25 | return nil, err |
| 26 | } |
| 27 | if len(stmts) == 0 { |
| 28 | return nil, nil |
| 29 | } |
| 30 | |
| 31 | var result []base.Statement |
| 32 | positionMapper := base.NewByteOffsetPositionMapper(statement) |
| 33 | for _, stmt := range stmts { |
| 34 | startPos := positionMapper.Position(stmt.ByteStart) |
| 35 | endPos := positionMapper.Position(stmt.ByteEnd) |
| 36 | |
| 37 | result = append(result, base.Statement{ |
| 38 | Text: stmt.Text, |
| 39 | Range: &storepb.Range{ |
| 40 | Start: int32(stmt.ByteStart), |
| 41 | End: int32(stmt.ByteEnd), |
| 42 | }, |
| 43 | Start: startPos, |
| 44 | End: endPos, |
| 45 | Empty: stmt.Empty(), |
| 46 | }) |
| 47 | } |
| 48 | return result, nil |
| 49 | } |
nothing calls this directly
no test coverage detected