Skip to content
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

data.query thought error sql.RawBytes about data type #69

Open
krisnamourt opened this issue Jun 17, 2022 · 0 comments
Open

data.query thought error sql.RawBytes about data type #69

krisnamourt opened this issue Jun 17, 2022 · 0 comments

Comments

@krisnamourt
Copy link

I'm having a problem with Aurora Cluster Mysql 5.7 data type

Terraform Version

Terraform v1.1.7
on linux_amd64

Affected Resource(s)

Please list the resources as a list, for example:

  • data.sql_query

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

data "sql_query" "users" {

  query = "select `user` from mysql.`user`"
  provider = sql.mysql_db_management
}
output "test"{
  value = data.sql_query.users.result
}

Debug Output

mysql_grant.devops_all_schemas_grant: Refreshing state... [id=test.user@%:`gk`]
╷
│ Error: unable to convert value from database: unable to determine type for "user": unexpected type for "user": "CHAR" (slice sql.RawBytes)
│ 
│   with data.sql_query.users,
│   on terrafile.tf line 40, in data "sql_query" "users":
│   40: data "sql_query" "users" {
│ 
╵

but if I change the query for

data "sql_query" "users" {

  query ="select CAST(`user` AS CHAR CHARACTER SET utf8) as user_name from mysql.`user`"
  provider = sql.mysql_db_management
}
output "test"{
  value = data.sql_query.users.result
}

Debug Output

  + test = [
      + {
          + user_name = "user.user"
        },
      + {
          + user_name = "airflow_dag"
        },
.....
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

No branches or pull requests

1 participant