Skip to content

Made a test case on working with privileges on columns such as FIRST, ID, KEY, LAST, ORDER, etc.#220

Closed
maximmasiutin wants to merge 1 commit intopetoju:masterfrom
maximmasiutin:feature/column-names
Closed

Made a test case on working with privileges on columns such as FIRST, ID, KEY, LAST, ORDER, etc.#220
maximmasiutin wants to merge 1 commit intopetoju:masterfrom
maximmasiutin:feature/column-names

Conversation

@maximmasiutin
Copy link
Contributor

@maximmasiutin maximmasiutin commented Apr 22, 2025

This pull request contains a case that illustrates privileges on columns with names such as FIRST, ID, KEY, LAST, ORDER, etc.

It illustrates #219. For example, MySQL does not allow the table column name key without backticks in grants.

This test on a valid terraform file gives the following error:

resource_grant_test.go:170: Step 3/12 error: Error running apply: exit status 1
  Error: failed updating privileges: Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'KEY, LAST, ORDER) ON `tf-test-27`.`tbl` TO 'jdoe-tf-test-27'@'example.com'' at line 1

    with mysql_grant.test,
    on terraform_plugin_test.tf line 24, in resource "mysql_grant" "test":
    24: resource "mysql_grant" "test" {

  testing_new.go:85: Error running post-test destroy, there may be dangling resources: exit status 1

Error: error revoking REVOKE SELECT(FIRST, ID, KEY, LAST, ORDER) ON `tf-test-27`.`tbl` FROM 'jdoe-tf-test-27'@'example.com': Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'KEY, LAST, ORDER) ON `tf-test-27`.`tbl` FROM 'jdoe-tf-test-27'@'example.com'' at line 1

The test first creates the table with the following columns:

(c1 INT, c2 INT, c3 INT, c4 INT, c5 INT, `id` INT, `key` INT, `order` INT, `type` INT, `status` INT, `created` INT, `updated` INT, `user` INT, `name` INT, `group` INT, `value` INT, `index` INT, `source` INT, `date` INT, `state` INT, `last` INT, `first` INT, `email` INT, `phone` INT, `amount` INT, `reference` INT, `reason` INT, `hash` INT, `team` INT, `case` INT, `uid` INT, `path` INT)

The table creates successfully. Then, on granting privileges on columns, there is an error.

The privilege being granted is the following:

SELECT (`id`,`key`,`order`,`first`,`last`)

…d such as `FIRST`, `ID`, `KEY`, `LAST`, `ORDER`, etc
@petoju
Copy link
Owner

petoju commented Apr 22, 2025

I believe this is included in just merged #222 - so closing it

@petoju petoju closed this Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants