Skip to content

Commit

Permalink
Fixes broken code (eatonphil#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
krischerven authored Apr 16, 2020
1 parent e7ff8cb commit afd6424
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io"
"os"
"strings"

"github.com/eatonphil/gosql"

Expand Down Expand Up @@ -100,6 +101,11 @@ repl:
continue repl
}

trimmedLine := strings.TrimRight(line, " ")
if trimmedLine == "quit" || trimmedLine == "exit" || strings.TrimLeft(trimmedLine, " ") == "\\q" {
break
}

ast, err := gosql.Parse(line)
if err != nil {
fmt.Println("Error while parsing:", err)
Expand All @@ -114,6 +120,12 @@ repl:
fmt.Println("Error creating table", err)
continue repl
}
case gosql.DropTableKind:
err = mb.DropTable(ast.Statements[0].DropTableStatement)
if err != nil {
fmt.Println("Error dropping table", err)
continue repl
}
case gosql.InsertKind:
err = mb.Insert(stmt.InsertStatement)
if err != nil {
Expand Down

0 comments on commit afd6424

Please sign in to comment.