From afd6424850dcb29ed57b8504f434bbd9a6fdf656 Mon Sep 17 00:00:00 2001 From: Kris Cherven <50562493+krischerven@users.noreply.github.com> Date: Wed, 15 Apr 2020 21:02:19 -0400 Subject: [PATCH] Fixes broken code (#10) --- cmd/main.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmd/main.go b/cmd/main.go index 1978f4a..07e65e6 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -4,6 +4,7 @@ import ( "fmt" "io" "os" + "strings" "github.com/eatonphil/gosql" @@ -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) @@ -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 {