Skip to content

Commit

Permalink
starting implementation tsquery filter
Browse files Browse the repository at this point in the history
fixed #486

Signed-off-by: Avelino <t@avelino.xxx>
  • Loading branch information
avelino committed Dec 31, 2020
1 parent c34b2a3 commit 3fb612a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion adapters/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ func (adapter *Postgres) WhereByRequest(r *http.Request, initialPlaceholderID in
jsonField[0] = fmt.Sprintf(`"%s"`, strings.Join(fields, `"."`))
whereKey = append(whereKey, fmt.Sprintf(`%s->>'%s' %s $%d`, jsonField[0], jsonField[1], op, pid))
values = append(values, value)
case "tsquery":
tsQueryField := strings.Split(keyInfo[0], "$")
tsQuery := fmt.Sprintf(`%s @@ to_tsquery('%s')`, tsQueryField[0], value)
if len(tsQueryField) == 2 {
tsQuery = fmt.Sprintf(`%s @@ to_tsquery('%s', '%s')`, tsQueryField[0], tsQueryField[1], value)
}
whereKey = append(whereKey, tsQuery)
default:
if chkInvalidIdentifier(keyInfo[0]) {
err = fmt.Errorf("invalid identifier: %s", keyInfo[0])
Expand Down Expand Up @@ -1061,7 +1068,6 @@ func GetQueryOperator(op string) (string, error) {

err := errors.New("Invalid operator")
return "", err

}

// TablePermissions get tables permissions based in prest configuration
Expand Down

0 comments on commit 3fb612a

Please sign in to comment.