doc: remove old comments, add newer todos
This commit is contained in:
parent
8e07b63877
commit
e08c84de3a
@ -24,7 +24,7 @@ type Conditional struct {
|
|||||||
Key string
|
Key string
|
||||||
Operator string
|
Operator string
|
||||||
Value 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
|
Extension string // AND, OR, etc
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ func GetQueryTypeFromToken(token *sqllexer.Token) QueryType {
|
|||||||
|
|
||||||
func IsCrudSqlStatement(token *sqllexer.Token) bool {
|
func IsCrudSqlStatement(token *sqllexer.Token) bool {
|
||||||
queryType := GetQueryTypeFromToken(token)
|
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 {
|
func IsTokenBeginingOfStatement(currentToken *sqllexer.Token, previousToken *sqllexer.Token) bool {
|
||||||
@ -114,10 +114,9 @@ func ExtractSqlStatmentsFromString(sqlString string) []string {
|
|||||||
} else {
|
} else {
|
||||||
continue
|
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
|
isBeginingFound = true
|
||||||
} else if !isBeginingFound {
|
} else if !isBeginingFound {
|
||||||
continue
|
continue
|
||||||
|
11
q/select.go
11
q/select.go
@ -1,13 +1,11 @@
|
|||||||
package q
|
package q
|
||||||
|
|
||||||
import (
|
import (
|
||||||
// "fmt"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/DataDog/go-sqllexer"
|
"github.com/DataDog/go-sqllexer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 126 rich mar drive
|
|
||||||
type Select struct {
|
type Select struct {
|
||||||
Table string
|
Table string
|
||||||
Columns []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) {
|
func unshiftBuffer(buf *[10]sqllexer.Token, value sqllexer.Token) {
|
||||||
for i := 9; i >= 1; i-- {
|
for i := 9; i >= 1; i-- {
|
||||||
buf[i] = buf[i-1]
|
buf[i] = buf[i-1]
|
||||||
@ -80,9 +77,8 @@ func ParseSelectStatement(sql string) Select {
|
|||||||
passedConditionals := false
|
passedConditionals := false
|
||||||
passedOrderByKeywords := false
|
passedOrderByKeywords := false
|
||||||
passesOrderByColumns := 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 workingConditional = Conditional{}
|
||||||
|
|
||||||
var columns []string
|
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
|
passedFROM = true
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -149,7 +146,7 @@ func ParseSelectStatement(sql string) Select {
|
|||||||
workingConditional.Operator = token.Value
|
workingConditional.Operator = token.Value
|
||||||
} else if token.Type == sqllexer.BOOLEAN || token.Type == sqllexer.NULL || token.Type == sqllexer.STRING || token.Type == sqllexer.NUMBER {
|
} else if token.Type == sqllexer.BOOLEAN || token.Type == sqllexer.NULL || token.Type == sqllexer.STRING || token.Type == sqllexer.NUMBER {
|
||||||
workingConditional.Value = token.Value
|
workingConditional.Value = token.Value
|
||||||
} // TODO: add captire for data type
|
}
|
||||||
|
|
||||||
if workingConditional.Key != "" && workingConditional.Operator != "" && workingConditional.Value != "" {
|
if workingConditional.Key != "" && workingConditional.Operator != "" && workingConditional.Value != "" {
|
||||||
query.Conditionals = append(query.Conditionals, workingConditional)
|
query.Conditionals = append(query.Conditionals, workingConditional)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user