-
Notifications
You must be signed in to change notification settings - Fork 67
Description
Bug Report
- Yes, I reviewed the contribution guidelines.
- Yes, more specifically, I reviewed the guidelines on how to write clear bug reports.
Describe the current, buggy behavior
When I run following command:
wp db query "select 1;" --defaults
the query fails with following message:
Error: Failed to get current SQL modes. Reason: '"mysql --no-defaults --no-auto-rehash --batch --skip-column-names --execute="SELECT' is not recognized as an internal or external command,
operable program or batch file.
When executing wp db query, than 2 SQL queries are executed internally:
- discover SQL mode
- execute actual query
The actual query for 2. is build first and calls DB_Command::get_defaults_flag_string() here. This method will remove the $assoc_args['defaults'] here. Afterwards when DB_Command:.get_sql_mode_query() is called here, than the defaults is not set anymore in $array_assoc. This results in adding --no-defaults to the query 1.
Describe how other contributors can replicate this bug
- Install WP-CLI 2.8.1
- Run
wp db query "SELECT 1;" --defaults - Interally
/usr/bin/env mysql --no-defaults /* snip */ --execute='SELECT @@SESSION.sql_mode'is executed first before/usr/bin/env mysql --execute='SELECT 1;'is called.
Describe what you would expect as the correct outcome
The "discover SQL mode" should also not add --no-defaults when wp db query {sql query} --defaults is executed.
Let us know what environment you are running this on
OS: Windows NT 10.0 build 22621 (Windows 10) AMD64
PHP version: 8.0.19
WP-CLI version: 2.8.1