small fixes

This commit is contained in:
2026-07-10 17:07:54 +01:00
parent 260506352f
commit 2a04163d6e
3 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"regexp"
)
var columnRegexp = regexp.MustCompile("^([^ ]+)( as ([^ ]+))?$")
var columnRegexp = regexp.MustCompile("^(.+)( as ([A-Za-z0-9_]+))?$")
type Column string
+5 -5
View File
@@ -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]
+1 -1
View File
@@ -2,7 +2,7 @@ package sqimple
import "regexp"
var whereRegexp = regexp.MustCompile("^((and|or) )?([^ ]+) (=|!=|>|>=|<|<=) ([^ ]+)?$")
var whereRegexp = regexp.MustCompile("^((and|or) )?(.+) (=|!=|>|>=|<|<=) (.+)?$")
type Where string