-
Notifications
You must be signed in to change notification settings - Fork 20
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
refactor: change the method of specifying query conditions #1388
base: main
Are you sure you want to change the base?
Conversation
) ([]*proto.AutoOpsRule, int, error) { | ||
var whereParts []mysql.WherePart = []mysql.WherePart{} | ||
var orderBySQL 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.
Zero value of string and int are "" and 0 already, so I think there won't be necessary to declare the value here! But if you want it to be clear for everyone, I think it's ok to keep it, I want to know your opinion 😅
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.
Revised query generation method and added ConstructQueryAndWhereArgs()
.
https://github.com/bucketeer-io/bucketeer/blob/update-storage-client-auto-ops-list-2/pkg/storage/v2/mysql/query.go#L341-L354
Generate a variable list of queries and Where clauses by passing a base query string and ListOptions.
@@ -9,4 +9,3 @@ SELECT | |||
status | |||
FROM | |||
auto_ops_rule | |||
%s %s %s |
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.
Previously, we were using %s
to add Where clause etc., to the query, but since we are using the below function to generate a common query, instead of using %s
we can add the required query to the base string. I changed it to add a string.
https://github.com/bucketeer-io/bucketeer/blob/update-storage-client-auto-ops-list-2/pkg/storage/v2/mysql/query.go#L341-L354
This pull request includes significant refactoring to improve the handling of query filters and options in the
AutoOpsService
and related storage components. The changes focus on replacing the existingWherePart
andOrder
structures with a more flexibleListOptions
structure, which encapsulates various filter types and query options.Part of #1252