-
Notifications
You must be signed in to change notification settings - Fork 0
Fixes TF drift for resource group name and query_limit #6
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
Conversation
@@ -34,8 +34,7 @@ func (rg *ResourceGroup) buildSQLQuery(prefix string) string { | |||
query = append(query, fmt.Sprintf(`PRIORITY = %s`, rg.Priority)) | |||
|
|||
if rg.QueryLimit != DefaultResourceGroup.QueryLimit { | |||
query = append(query, fmt.Sprintf(`QUERY_LIMIT=%s`, rg.QueryLimit)) | |||
|
|||
query = append(query, fmt.Sprintf(`QUERY_LIMIT=(%s)`, rg.QueryLimit)) |
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.
We rely on wrapping the query_limit in parentheses here instead of assuming that it will be wrapped in parentheses by the caller.
@@ -126,7 +126,7 @@ func DeleteResourceGroupUser(ctx context.Context, d *schema.ResourceData, meta i | |||
} | |||
|
|||
func readUserFromDB(db *sql.DB, name string) (string, string, error) { | |||
selectUsersQuery := `SELECT USER, IFNULL(JSON_EXTRACT(User_attributes, "$.resource_group"), "") as resource_group FROM mysql.user WHERE USER = ?` | |||
selectUsersQuery := `SELECT USER, JSON_UNQUOTE(IFNULL(JSON_EXTRACT(User_attributes, "$.resource_group"), "")) as resource_group FROM mysql.user WHERE USER = ?` |
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 gets rid of the quotes that JSON_EXTRACT
will generate.
GNUmakefile
Outdated
@@ -43,7 +43,12 @@ bin/terraform: | |||
(cd $(CURDIR)/bin/ ; unzip terraform.zip) | |||
|
|||
testacc: fmtcheck bin/terraform | |||
PATH="$(CURDIR)/bin:${PATH}" TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout=90s |
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 will be a potentially breaking change to upstream
GNUmakefile
Outdated
# Commenting out the below because it tries to use an amd64 version of terraform that is incompatible with M1 Macs. Instead, | ||
# simply rely on the version of terraform that's already on your path. If you don't have terraform installed, follow instructions | ||
# here to install https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli | ||
# PATH="$(CURDIR)/bin:${PATH}" TF_ACC=1 go test $(TEST) -v $(TESTARGS) -run "TestTIDBResourceGroup_basic" -timeout=90s |
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 need this as a separate section in Makefile or can we remove it since I've patched the ARCH problem?
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.
I'm removing it since it's patched for ARCH above.
LMK if you disagree
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.
Sounds good! Thanks for fixing this 👍
This fixes the following drift:
()
parentheses when pulled from the DB. This PR standardizes around the query_limit inside the parentheses. A breaking change is that we expect NO parenthesis to be passed in for the query_limit from now on. Instead, we will wrap the query_limit inside parentheses in the actual query rather than rely on the query_limit string being wrapped in parentheses by the caller.I also got basic tidb tests working and tested the above changes using
make testtidb7.5.1