sous-chefs / mysql

Development repository for the mysql cookbook
https://supermarket.chef.io/cookbooks/mysql
Apache License 2.0
338 stars 690 forks source link

"No database selected" when calling mysql_database resource #678

Closed jhou4 closed 2 years ago

jhou4 commented 2 years ago

:speaking_head: Foreword

Thank for taking the time to fill this bug report fully. Without it we may not be able to fix the bug, and the issue may be closed without resolution.

:ghost: Brief Description

When calling mysql_database resource to execute a query(query action), resource fails with "No database selected" error.

:pancakes: Cookbook version

11.0.3

:woman_cook: Chef-Infra Version

cinc-client 16.16.13

:tophat: Platform details

Redhat server 7.6

Steps To Reproduce

Steps to reproduce the behavior:

  1. Construct a sql query
  2. Call mysql_database resource to execute the query.
  3. See error

:police_car: Expected behavior

Query to be executed without error.

:heavy_plus_sign: Additional context

Problem seems to be with this line: https://github.com/sous-chefs/mysql/blob/main/resources/mysql_database.rb#L60 where database name is skipped when executing a query action, while the function clearly requires the database name: https://github.com/sous-chefs/mysql/blob/main/resources/mysql_database.rb#L84