-
Notifications
You must be signed in to change notification settings - Fork 917
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
Support CountWorkflowExecutions for SQL DB #3955
Support CountWorkflowExecutions for SQL DB #3955
Conversation
tests/advanced_visibility_test.go
Outdated
if !s.isElasticsearchEnabled() { | ||
s.T().Skip("This test is only for Elasticsearch") | ||
} | ||
|
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.
👍
} | ||
|
||
return fmt.Sprintf( | ||
"SELECT COUNT(1) FROM executions_visibility WHERE %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.
Had to use ChatGPT to explain me what is COUNT(1)
and why it is better than COUNT(*)
.
8d91f85
to
58868f4
Compare
queryArgs = append(queryArgs, namespaceID.String()) | ||
|
||
if len(queryString) > 0 { | ||
whereClauses = append(whereClauses, fmt.Sprintf("(%s)", queryString)) |
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.
Do we have sql injection risk here?
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.
It shouldn't. The query converter escape the user's input.
return fmt.Sprintf( | ||
`SELECT COUNT(1) | ||
FROM executions_visibility ev | ||
LEFT JOIN custom_search_attributes |
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.
Is join here must have? PostgreSQL and SQLite were able to get away without join.
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.
Yes, in MySQL, we have two tables (executions + custom search attributes), so we need the join. I'm assuming the input can be on any search attribute. If it's only on system search attribute, we can remove the join.
What changed?
Implement support for
CountWorkflowExecutions
for advanced visibility with SQL DB.Why?
Advanced visibility with SQL DB.
How did you test it?
Enabled
TestCountWorkflow
functional test.Potential risks
No risks.
Is hotfix candidate?
No.