MCPcopy Index your code
hub / github.com/LissaGreense/GO4SQL / Evaluate

Method Evaluate

engine/engine.go:27–92  ·  view source on GitHub ↗

Evaluate - it takes sequences, map them to specific implementation and then process it in SQL engine

(sequences *ast.Sequence)

Source from the content-addressed store, hash-verified

25
26// Evaluate - it takes sequences, map them to specific implementation and then process it in SQL engine
27func (engine *DbEngine) Evaluate(sequences *ast.Sequence) (string, error) {
28 commands := sequences.Commands
29
30 result := ""
31 for _, command := range commands {
32
33 switch mappedCommand := command.(type) {
34 case *ast.WhereCommand:
35 continue
36 case *ast.OrderByCommand:
37 continue
38 case *ast.LimitCommand:
39 continue
40 case *ast.OffsetCommand:
41 continue
42 case *ast.JoinCommand:
43 continue
44 case *ast.CreateCommand:
45 err := engine.createTable(mappedCommand)
46 if err != nil {
47 return "", err
48 }
49 result += "Table '" + mappedCommand.Name.GetToken().Literal + "' has been created\n"
50 continue
51 case *ast.InsertCommand:
52 err := engine.insertIntoTable(mappedCommand)
53 if err != nil {
54 return "", err
55 }
56 result += "Data Inserted\n"
57 continue
58 case *ast.SelectCommand:
59 selectOutput, err := engine.getSelectResponse(mappedCommand)
60 if err != nil {
61 return "", err
62 }
63 result += selectOutput.ToString() + "\n"
64 continue
65 case *ast.DeleteCommand:
66 deleteCommand := command.(*ast.DeleteCommand)
67 if deleteCommand.HasWhereCommand() {
68 err := engine.deleteFromTable(mappedCommand, deleteCommand.WhereCommand)
69 if err != nil {
70 return "", err
71 }
72 }
73 result += "Data from '" + mappedCommand.Name.GetToken().Literal + "' has been deleted\n"
74 continue
75 case *ast.DropCommand:
76 engine.dropTable(mappedCommand)
77 result += "Table: '" + mappedCommand.Name.GetToken().Literal + "' has been dropped\n"
78 continue
79 case *ast.UpdateCommand:
80 err := engine.updateTable(mappedCommand)
81 if err != nil {
82 return "", err
83 }
84 result += "Table: '" + mappedCommand.Name.GetToken().Literal + "' has been updated\n"

Callers 6

runTestSuiteMethod · 0.80
runTestSuiteMethod · 0.80
getErrorMessageFunction · 0.80
HandleFileModeFunction · 0.80
HandleStreamModeFunction · 0.80
handleSocketClientFunction · 0.80

Calls 9

createTableMethod · 0.95
insertIntoTableMethod · 0.95
getSelectResponseMethod · 0.95
deleteFromTableMethod · 0.95
dropTableMethod · 0.95
updateTableMethod · 0.95
GetTokenMethod · 0.65
ToStringMethod · 0.65
HasWhereCommandMethod · 0.45

Tested by 3

runTestSuiteMethod · 0.64
runTestSuiteMethod · 0.64
getErrorMessageFunction · 0.64