small fixes
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
||||
"regexp"
|
||||
)
|
||||
|
||||
var columnRegexp = regexp.MustCompile("^([^ ]+)( as ([^ ]+))?$")
|
||||
var columnRegexp = regexp.MustCompile("^(.+)( as ([A-Za-z0-9_]+))?$")
|
||||
|
||||
type Column string
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
insertTableRegexp = regexp.MustCompile("^into ([^ ]+)( (as) ([^ ]+))?$")
|
||||
selectTableRegexp = regexp.MustCompile("^(from|left join|inner join|right join) ([^ ]+)( (as) ([^ ]+))?( (on) ([^ ]+) (=|!=|>|>=|<|<=) ([^ ]+)( (and) ([^ ]+) (=|!=|>|>=|<|<=) ([^ ]+))*)?$")
|
||||
updateTableRegexp = regexp.MustCompile("^([^ ]+)( (as) ([^ ]+))?$")
|
||||
insertTableRegexp = regexp.MustCompile("^into ([A-Za-z0-9_]+)( (as) ([A-Za-z0-9_]+))?$")
|
||||
selectTableRegexp = regexp.MustCompile("^(from|left join|inner join|right join) ([A-Za-z0-9_]+)( (as) ([A-Za-z0-9_]+))?( (on) ([^ ]+) (=|!=|>|>=|<|<=) ([^ ]+)( (and) ([^ ]+) (=|!=|>|>=|<|<=) ([^ ]+))*)?$")
|
||||
updateTableRegexp = regexp.MustCompile("^(.+)( (as) ([A-Za-z0-9_]+))?$")
|
||||
)
|
||||
|
||||
type InsertTable string
|
||||
@@ -125,14 +125,14 @@ func RightJoin(def string) SelectTable {
|
||||
type UpdateTable string
|
||||
|
||||
func (t UpdateTable) IsValid() bool {
|
||||
return insertTableRegexp.MatchString(string(t))
|
||||
return updateTableRegexp.MatchString(string(t))
|
||||
}
|
||||
|
||||
func (t UpdateTable) Parse() (table, as string, ok bool) {
|
||||
if insertTableRegexp.MatchString(string(t)) {
|
||||
ok = true
|
||||
|
||||
result := insertTableRegexp.FindAllStringSubmatch(string(t), -1)
|
||||
result := updateTableRegexp.FindAllStringSubmatch(string(t), -1)
|
||||
|
||||
for _, r := range result {
|
||||
table = r[1]
|
||||
|
||||
Reference in New Issue
Block a user