-
Notifications
You must be signed in to change notification settings - Fork 203
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
Update MySQL user roles when users are modified #1317
Conversation
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 looks good, but possibly there's a way to get the role information in a more machine-readable format.
5c378f9
to
8becf7e
Compare
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 great with one tweak - user can be a parameter for the extract roles query.
tsql := fmt.Sprintf("SELECT PRIVILEGE_TYPE from information_schema.SCHEMA_PRIVILEGES WHERE GRANTEE = '''%s''@''%%''' and TABLE_SCHEMA = ?", user) | ||
rows, err := db.QueryContext(ctx, tsql, database) |
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.
Grantee can be a parameter here, can't it? You'd still have to build the weird formatting with the quotes and @ - that's a bit easier if you don't need to sql-quote it.
tsql := fmt.Sprintf("SELECT PRIVILEGE_TYPE from information_schema.SCHEMA_PRIVILEGES WHERE GRANTEE = '''%s''@''%%''' and TABLE_SCHEMA = ?", user) | |
rows, err := db.QueryContext(ctx, tsql, database) | |
tsql := "select privilege_type from information_schema.schema_privileges where grantee = ? and table_schema= ?" | |
formattedUser := fmt.Sprintf("'%s'@'%'", user) | |
rows, err := db.QueryContext(ctx, tsql, formattedUser, database) |
I tend to make queries all lowercase, not sure what the standard is - a lot of people prefer SQL keywords in uppercase.
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.
Yeah all of the existing queries we have are all uppercase for the keywords at least. I'll fix this
8becf7e
to
60c1f5d
Compare
This is related to but does not resolve #1311
What this PR does / why we need it:
We need to decide if we want to support this functionality at all. It's "easiest" for MySQL and harder for Azure SQL (I haven't even looked into PostgreSQL).
If applicable: