Skip to content

Commit

Permalink
wip rework
Browse files Browse the repository at this point in the history
  • Loading branch information
its-felix committed Dec 8, 2023
1 parent 5cc4e98 commit ccab53b
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions web/dev_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ func translateQuery(paramNum int, query cloudscapeQuery) (string, []any, error)
">=": ">=",
"<": "<",
"<=": "<=",
":": "=", // special case for authorized_scopes
"!:": "!=", // special case for authorized_scopes
":": "=",
"!:": "!=",
}

builder := util.NewSQLBuilder(paramNum)
Expand All @@ -264,13 +264,6 @@ func translateQuery(paramNum int, query cloudscapeQuery) (string, []any, error)
}

if tk.PropertyKey == "authorized_scopes" {
prefix := ""
suffix := ""
if strings.HasPrefix(tk.Operator, "!") {
prefix = "NOT ("
suffix = ")"
}

var values []any
if tk.Value == "" {
values = []any{}
Expand All @@ -283,25 +276,18 @@ func translateQuery(paramNum int, query cloudscapeQuery) (string, []any, error)

if tk.Operator == ":" || tk.Operator == "!:" {
builder.AddSlice(values, func(nums []int) string {
return fmt.Sprintf("%s%s = ANY ARRAY[ %s ]%s", prefix, prop, strings.Join(util.SQLParams(nums), ","), suffix)
return fmt.Sprintf("%s %s ANY ARRAY[ %s ]", prop, op, strings.Join(util.SQLParams(nums), ","))
})
/*
builder.Add(values, func(i int) string {
return fmt.Sprintf("%s%s = ANY(%s)%s", prefix, prop, util.SQLParam(i), suffix)
})
*/
} else {
builder.AddSlice(values, func(nums []int) string {
return fmt.Sprintf("%s%s = ARRAY[ %s ]%s", prefix, prop, strings.Join(util.SQLParams(nums), ","), suffix)
return fmt.Sprintf("%s %s ARRAY[ %s ]", prop, op, strings.Join(util.SQLParams(nums), ","))
})
}
} else {
builder.Add(tk.Value, func(i int) string {
return fmt.Sprintf("%s %s %s", prop, op, util.SQLParam(i))
})
}

paramNum++
}

operation, ok := operationToSQL[query.Operation]
Expand Down

0 comments on commit ccab53b

Please sign in to comment.