-
Notifications
You must be signed in to change notification settings - Fork 109
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
BED-4726 added new ~eq predicate for filtering on strings #808
Changes from 10 commits
083eac6
ea97ba3
9bd06c8
96ab706
9ec87a7
6c984de
b4b1637
73214e2
3509caf
f7fd132
fa07d65
653ad95
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- Copyright 2024 Specter Ops, Inc. | ||
-- | ||
-- Licensed under the Apache License, Version 2.0 | ||
-- you may not use this file except in compliance with the License. | ||
-- You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software | ||
-- distributed under the License is distributed on an "AS IS" BASIS, | ||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
-- See the License for the specific language governing permissions and | ||
-- limitations under the License. | ||
-- | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
CREATE EXTENSION IF NOT EXISTS pg_trgm; | ||
|
||
CREATE INDEX IF NOT EXISTS idx_saved_queries_description ON saved_queries using gin(description gin_trgm_ops); | ||
CREATE INDEX IF NOT EXISTS idx_saved_queries_name ON saved_queries USING gin(name gin_trgm_ops); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,13 +39,15 @@ const ( | |
LessThanOrEquals FilterOperator = "lte" | ||
Equals FilterOperator = "eq" | ||
NotEquals FilterOperator = "neq" | ||
ApproximatelyEquals FilterOperator = "~eq" | ||
|
||
GreaterThanSymbol string = ">" | ||
GreaterThanOrEqualsSymbol string = ">=" | ||
LessThanSymbol string = "<" | ||
LessThanOrEqualsSymbol string = "<=" | ||
EqualsSymbol string = "=" | ||
NotEqualsSymbol string = "<>" | ||
ApproximatelyEqualSymbol string = "ILIKE" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ILIKE it! |
||
|
||
TrueString = "true" | ||
FalseString = "false" | ||
|
@@ -79,6 +81,9 @@ func ParseFilterOperator(raw string) (FilterOperator, error) { | |
case NotEquals: | ||
return NotEquals, nil | ||
|
||
case ApproximatelyEquals: | ||
return ApproximatelyEquals, nil | ||
|
||
default: | ||
return "", fmt.Errorf("unknown query parameter filter predicate: %s", raw) | ||
} | ||
|
@@ -165,6 +170,9 @@ func (s QueryParameterFilterMap) BuildSQLFilter() (SQLFilter, error) { | |
predicate = EqualsSymbol | ||
case NotEquals: | ||
predicate = NotEqualsSymbol | ||
case ApproximatelyEquals: | ||
predicate = ApproximatelyEqualSymbol | ||
filter.Value = fmt.Sprintf("%%%s%%", filter.Value) | ||
default: | ||
return SQLFilter{}, fmt.Errorf("invalid filter predicate specified") | ||
} | ||
|
@@ -344,6 +352,6 @@ func (s QueryParameterFilterParser) ParseQueryParameterFilters(request *http.Req | |
|
||
func NewQueryParameterFilterParser() QueryParameterFilterParser { | ||
return QueryParameterFilterParser{ | ||
re: regexp.MustCompile(`([\w]+):([\w\d\--_]+)`), | ||
re: regexp.MustCompile(`([~\w]+):([\w\--_ ]+)`), | ||
mistahj67 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13929,7 +13929,7 @@ | |
}, | ||
"api.params.predicate.filter.string": { | ||
"type": "string", | ||
"description": "Filter results by column string value. Valid filter predicates are `eq`, `neq`.\n" | ||
"description": "Filter results by column string value. Valid filter predicates are `eq`, `neq`, `~eq`.\n" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit but should There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can see that, it's related to |
||
}, | ||
"api.params.predicate.filter.integer": { | ||
"type": "integer", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be v5.16.0 correct? Or is the goal to have this in the upcoming release?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably cutting it close to the next release since we're about to cut the RC.
I'll throw it in for v5.16.0