-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fixes PLIN-2287 Improve Picard Filtering #80
Conversation
if filters != nil && len(filters) > 0 && modelVal != nil { | ||
for _, filter := range filters { | ||
fieldMetadata := filterMetadata.GetField(filter.FieldName) | ||
tbl.AddWhere(fieldMetadata.GetColumnName(), filter.FilterValue) |
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.
Does this still work if we have multiple filter values on the same field? The way I read the squirrel docs, it defaults to AND
, so (assuming column name is id
and filter.FilterValue
is foo
etc.) this will add WHERE id=foo AND id=bar AND id=baz
, so we end up getting nothing back. That's why I added WHERE id IN (foo, bar, baz)
instead.
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.
Line 83 in 5ff5724
ands = append(ands, sq.Eq{ |
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.
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.
Ah, cool. Thanks for figuring this out.
@@ -63,6 +63,7 @@ func buildQuery( | |||
modelVal *reflect.Value, | |||
filters []qp.FieldFilter, | |||
associations []tags.Association, | |||
selectFields []string, |
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.
Update docstring above?
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.
good catch, I'll fix it.
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.
Fixed!
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.
Looks good. Thanks for taking the time to circle back and clean up my quick fix.
Adds FieldFilters to FilterRequests. Since FilterModels must be an actual instance of the struct being queried, we cannot add special filters like whereIn with a FilterModel. This PR adds FieldFilters to allow for more complex filters.
Improve performance by using cached struct metadata instead of getting it on each iteration of a loop. This completely removes struct metadata gathering from the hydrate function, which was getting called for each record returned. If we can rely on the trace PDF that I saw in another ticket, I believe this should be helpful.
Removes the ReflectTableInfo and GetPK functions in favor of previously existing functions.