-
Notifications
You must be signed in to change notification settings - Fork 0
Fix --defaults flag issue in SQL mode discovery for db query commands #2
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: lkraav <147228+lkraav@users.noreply.github.com>
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 issue is really not related specifically to SQL mode discovery, but rather how wp db query
loses any general arguments given to it, such as --defaults
, or as another use case example, --ssl-verify-server-cert
.
All these args work correctly for wp db cli
, so maybe we could explore how wp db query
is different and how wp db cli
succeeds in managing retaining cmdline args better.
You're right that this is a broader architectural issue. The problem is that Looking at the difference:
Would you prefer a solution that makes the flag handling non-destructive across all commands, or should we explore having SQL mode discovery take a different approach that doesn't rely on re-parsing the args? I'm curious what specific architectural change you'd like to see explored. |
Let's try to fix Here's debug output of failure
|
You're right, the issue is broader than just the Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
- Replace empty foreach loop in get_current_sql_modes() with proper MySQL argument preservation using get_mysql_args() - Add ssl-verify-server-cert to allowed MySQL options list - Add test case to verify connection arguments are preserved during SQL mode discovery - Fixes issue where connection flags like --ssl-verify-server-cert were lost during SQL mode discovery Co-authored-by: lkraav <147228+lkraav@users.noreply.github.com>
The
--defaults
flag was being incorrectly ignored during SQL mode discovery, causing commands likewp db query "SELECT 1;" --defaults
to fail with MySQL connection errors.Problem
When using the
--defaults
flag withwp db query
, the command would fail during SQL mode discovery with an error like:Root Cause
The issue occurred because
get_defaults_flag_string()
modifies the$assoc_args
array by reference, removing the 'defaults' key after processing it. This caused a sequence problem:get_defaults_flag_string($assoc_args)
→ returns empty string (correct), removes 'defaults' keyget_sql_mode_query($assoc_args)
→ internally callsget_defaults_flag_string($assoc_args)
again--no-defaults
flag--no-defaults
when user specified--defaults
Solution
Preserve the original
$assoc_args
before the first call toget_defaults_flag_string()
and pass the original arguments toget_sql_mode_query()
:Changes Made
query()
,import()
, andrun_query()
--defaults
flagTesting
Added a new test scenario in
features/db-query.feature
:Fixes #1.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/Behat/Gherkin/zipball/34c9b59c59355a7b4c53b9f041c8dbd1c8acc3b4
/usr/bin/php8.3 -n -c /tmp/RCdY1Y /usr/bin/composer install
(http block)https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3
/usr/bin/php8.3 -n -c /tmp/RCdY1Y /usr/bin/composer install
(http block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.