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