Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ILIKE to the list of comparators #128

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 35 additions & 36 deletions components/ResultsTable.go
Original file line number Diff line number Diff line change
Expand Up @@ -1220,68 +1220,67 @@ func (table *ResultsTable) search() {

table.Filter.Input.SetAutocompleteFunc(func(currentText string) []string {
split := strings.Split(currentText, " ")
comparators := []string{"=", "!=", ">", "<", ">=", "<=", "LIKE", "NOT LIKE", "IN", "NOT IN", "IS", "IS NOT", "BETWEEN", "NOT BETWEEN"}
comparators := []string{
"=", "!=",
">", "<",
">=", "<=",
"between", "not between",
"ilike", "not ilike",
"in", "not in",
"is", "is not",
"like", "not like",
"regexp", "not regexp",
}

if len(split) == 1 {
columns := table.GetColumns()
columnNames := []string{}
matches := []string{}

for i, col := range columns {
if i > 0 {
columnNames = append(columnNames, col[0])
}
switch len(split) {
case 1:
for _, col := range table.GetColumns()[1:] {
matches = append(matches, col[0])
}

return columnNames
} else if len(split) == 2 {

for i, comparator := range comparators {
comparators[i] = fmt.Sprintf("%s %s", split[0], strings.ToLower(comparator))
case 2:
for _, comparator := range comparators {
if strings.HasPrefix(comparator, split[1]) {
matches = append(matches, fmt.Sprintf("%s %s", split[0], comparator))
}
}

return comparators
} else if len(split) == 3 {

ret := true

case 3:
switch split[1] {
case "not":
comparators = []string{"between", "in", "like"}
comparators = []string{"between", "ilike", "in", "like", "regexp"}
case "is":
comparators = []string{"not", "null"}
default:
ret = false
return matches
}

if ret {
for i, comparator := range comparators {
comparators[i] = fmt.Sprintf("%s %s %s", split[0], split[1], strings.ToLower(comparator))
for _, comparator := range comparators {
if strings.HasPrefix(comparator, split[2]) {
matches = append(matches, fmt.Sprintf("%s %s %s", split[0], split[1], comparator))
}
return comparators
}

} else if len(split) == 4 {
ret := true

case 4:
switch split[2] {
case "not":
comparators = []string{"null"}
case "is":
comparators = []string{"not", "null"}
default:
ret = false
return matches
}

if ret {
for i, comparator := range comparators {
comparators[i] = fmt.Sprintf("%s %s %s %s", split[0], split[1], split[2], strings.ToLower(comparator))
for _, comparator := range comparators {
if strings.HasPrefix(comparator, split[3]) {
matches = append(matches,
fmt.Sprintf("%s %s %s %s", split[0], split[1], split[2], comparator),
)
}

return comparators
}
}

return []string{}
return matches
})

table.Filter.Input.SetAutocompletedFunc(func(text string, _ int, source int) bool {
Expand Down