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

Method createTable

engine/engine.go:152–169  ·  view source on GitHub ↗

createTable - initialize new table in engine with specified name

(command *ast.CreateCommand)

Source from the content-addressed store, hash-verified

150
151// createTable - initialize new table in engine with specified name
152func (engine *DbEngine) createTable(command *ast.CreateCommand) error {
153 _, exist := engine.Tables[command.Name.Token.Literal]
154
155 if exist {
156 return &TableAlreadyExistsError{command.Name.Token.Literal}
157 }
158
159 engine.Tables[command.Name.Token.Literal] = &Table{Columns: []*Column{}}
160 for i, columnName := range command.ColumnNames {
161 engine.Tables[command.Name.Token.Literal].Columns = append(engine.Tables[command.Name.Token.Literal].Columns,
162 &Column{
163 Type: command.ColumnTypes[i],
164 Values: make([]ValueInterface, 0),
165 Name: columnName,
166 })
167 }
168 return nil
169}
170
171func (engine *DbEngine) updateTable(command *ast.UpdateCommand) error {
172 table, exist := engine.Tables[command.Name.Token.Literal]

Callers 1

EvaluateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected