initial commit

This commit is contained in:
2026-07-07 17:25:02 +01:00
commit daff6a8f09
12 changed files with 562 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
package simql
import "regexp"
var whereRegexp = regexp.MustCompile("^((and|or) )?([^ ]+) (=|!=|>|>=|<|<=) ([^ ]+)?$")
type Where string
func (w Where) IsValid() bool {
return whereRegexp.MatchString(string(w))
}
func (w Where) Parse() (glue, column, operator string, value any, ok bool) {
if whereRegexp.MatchString(string(w)) {
ok = true
result := whereRegexp.FindAllStringSubmatch(string(w), -1)
for _, r := range result {
glue, column, operator, value = r[2], r[3], r[4], r[5]
if value == "?" {
value = nil
}
}
}
return
}
func (w Where) String() string {
return string(w)
}