diff --git a/q/query.go b/q/query.go index 38040f2..904d0db 100644 --- a/q/query.go +++ b/q/query.go @@ -24,7 +24,7 @@ type Conditional struct { Key string Operator string Value string - DataType string + DataType string // TODO: not something we can parse from string, but find a way to determine this later Extension string // AND, OR, etc } @@ -52,7 +52,7 @@ func GetQueryTypeFromToken(token *sqllexer.Token) QueryType { func IsCrudSqlStatement(token *sqllexer.Token) bool { queryType := GetQueryTypeFromToken(token) - return (queryType > 0 && queryType <= 4) // TODO: Update if QueryTypes Change + return (queryType > 0 && queryType <= 4) } func IsTokenBeginingOfStatement(currentToken *sqllexer.Token, previousToken *sqllexer.Token) bool { @@ -114,10 +114,9 @@ func ExtractSqlStatmentsFromString(sqlString string) []string { } else { continue } - } - if !isBeginingFound && IsTokenBeginingOfStatement(token, &previousScannedToken) { // TODO: add logic that checks if begining is already found, if so an error should happen before here + if !isBeginingFound && IsTokenBeginingOfStatement(token, &previousScannedToken) { isBeginingFound = true } else if !isBeginingFound { continue diff --git a/q/select.go b/q/select.go index 07d7244..097294f 100644 --- a/q/select.go +++ b/q/select.go @@ -1,13 +1,11 @@ package q import ( - // "fmt" "strings" "github.com/DataDog/go-sqllexer" ) -// 126 rich mar drive type Select struct { Table string Columns []string @@ -60,7 +58,6 @@ func mutateSelectFromKeyword(query *Select, keyword string) { } } -// TODO: make this an array of tokens instead func unshiftBuffer(buf *[10]sqllexer.Token, value sqllexer.Token) { for i := 9; i >= 1; i-- { buf[i] = buf[i-1] @@ -80,9 +77,8 @@ func ParseSelectStatement(sql string) Select { passedConditionals := false passedOrderByKeywords := false passesOrderByColumns := false - //checkForOrderDirection := false - lookBehindBuffer := [10]sqllexer.Token{} // TODO: make this an array of tokens instead + lookBehindBuffer := [10]sqllexer.Token{} var workingConditional = Conditional{} var columns []string @@ -124,7 +120,8 @@ func ParseSelectStatement(sql string) Select { } } - if !passedFROM && strings.ToUpper(token.Value) == "FROM" { // TODO: make sure to check for other keywords that are allowed + // TODO: make sure to check for other keywords that are allowed + if !passedFROM && strings.ToUpper(token.Value) == "FROM" { passedFROM = true continue } @@ -149,7 +146,7 @@ func ParseSelectStatement(sql string) Select { workingConditional.Operator = token.Value } else if token.Type == sqllexer.BOOLEAN || token.Type == sqllexer.NULL || token.Type == sqllexer.STRING || token.Type == sqllexer.NUMBER { workingConditional.Value = token.Value - } // TODO: add captire for data type + } if workingConditional.Key != "" && workingConditional.Operator != "" && workingConditional.Value != "" { query.Conditionals = append(query.Conditionals, workingConditional)