From 2a04163d6eff408ff622b4e0f601c670763ba0a2 Mon Sep 17 00:00:00 2001 From: Aneurin Barker Snook Date: Fri, 10 Jul 2026 17:07:54 +0100 Subject: [PATCH] small fixes --- column.go | 2 +- table.go | 10 +++++----- where.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/column.go b/column.go index f794c1b..8efa99b 100644 --- a/column.go +++ b/column.go @@ -4,7 +4,7 @@ import ( "regexp" ) -var columnRegexp = regexp.MustCompile("^([^ ]+)( as ([^ ]+))?$") +var columnRegexp = regexp.MustCompile("^(.+)( as ([A-Za-z0-9_]+))?$") type Column string diff --git a/table.go b/table.go index 2f4f95d..13638d2 100644 --- a/table.go +++ b/table.go @@ -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] diff --git a/where.go b/where.go index 4a23276..ab49c50 100644 --- a/where.go +++ b/where.go @@ -2,7 +2,7 @@ package sqimple import "regexp" -var whereRegexp = regexp.MustCompile("^((and|or) )?([^ ]+) (=|!=|>|>=|<|<=) ([^ ]+)?$") +var whereRegexp = regexp.MustCompile("^((and|or) )?(.+) (=|!=|>|>=|<|<=) (.+)?$") type Where string