mirror of
https://github.com/safing/portbase
synced 2026-04-28 11:50:02 +00:00
Add query package with first set of conditions and tests
This commit is contained in:
parent
1bf7e42d8a
commit
6ed50f34fb
16 changed files with 933 additions and 0 deletions
44
database/query/parser.go
Normal file
44
database/query/parser.go
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
package query
|
||||
|
||||
var (
|
||||
operatorNames = map[string]uint8{
|
||||
"==": Equals,
|
||||
">": GreaterThan,
|
||||
">=": GreaterThanOrEqual,
|
||||
"<": LessThan,
|
||||
"<=": LessThanOrEqual,
|
||||
"f==": FloatEquals,
|
||||
"f>": FloatGreaterThan,
|
||||
"f>=": FloatGreaterThanOrEqual,
|
||||
"f<": FloatLessThan,
|
||||
"f<=": FloatLessThanOrEqual,
|
||||
"sameas": SameAs,
|
||||
"s==": SameAs,
|
||||
"contains": Contains,
|
||||
"co": Contains,
|
||||
"startswith": StartsWith,
|
||||
"sw": StartsWith,
|
||||
"endswith": EndsWith,
|
||||
"ew": EndsWith,
|
||||
"in": In,
|
||||
"matches": Matches,
|
||||
"re": Matches,
|
||||
"is": Is,
|
||||
"exists": Exists,
|
||||
"ex": Exists,
|
||||
}
|
||||
)
|
||||
|
||||
func getOpName(operator uint8) string {
|
||||
for opName, op := range operatorNames {
|
||||
if op == operator {
|
||||
return opName
|
||||
}
|
||||
}
|
||||
return "[unknown]"
|
||||
}
|
||||
|
||||
// ParseQuery parses a plaintext query.
|
||||
func ParseQuery(query string) (*Query, error) {
|
||||
return nil, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue