-
Notifications
You must be signed in to change notification settings - Fork 62
Add Affected Rows Count for queries that can modify data in wp db query #277
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
Add Affected Rows Count for queries that can modify data in wp db query #277
Conversation
Thanks for your pull request! A few tests now need to be updated because the expected output changed. Would you be up for taking a look at those and updating the tests? |
@swissspidy - Could you please provide any insights or recommendations on resolving the "Testing / test / Functional" issues? Any guidance would be greatly appreciated! Thanks in advance for your help. |
What’s the issue specifically? Are you able to run tests locally?
With the new output, some of the expected output in tests has changed and needs updating. Unfortunately we don’t have a good diff if the expected output changed, but you could also try running the commands from the test locally against your database. On that note, I don‘t get the recent |
@swissspidy - I have updated your feedbacks and I think only this test ( composer behat features/db-query.feature ) is failing in local and can you provide some insights to fix those. Thanks.
|
Look at the actual test and what it does: db-command/features/db-query.feature Lines 17 to 22 in e9c4e8a
With your PR, if you now run That's because it prevents default output and only calls I just pushed such a change to demonstrate it. |
@swissspidy – Most of the tests are now running successfully in the local environment. However, there is one remaining issue with composer behat features/db.feature, where the test fails due to a "Table 'custom_table' already exists" error. Interestingly, if I manually remove the table and re-run the command, it executes without any issues. Would you have any recommendations on how to best resolve this? Perhaps handling table cleanup within the test setup or ensuring the table is dropped before execution? Looking forward to your insights!
|
@karthick-murugan That's a fallacy. It isn't because of the table existing. Tests already clean up the database, but if you of course run the commands manually then you'll get an error about the table existing What happened is that the test expected STDOUT to be empty, but my previous change printed an empty line. This is now fixed. All tests (with the exception of the SQLIte ones) now pass :) |
Now what's missing is adding new tests to verify that this change works as expected. |
@karthick-murugan Note that the expected output needs to be on its own line. Look at other tests to see how the formatting is supposed to be. |
Thanks @swissspidy I was able to fix those errors. Now only the errors from SQLite remains. Can you provide me some insights?
|
Those are expected, see #234 |
Thanks @swissspidy for the information. Hope we can move forward with this PR. |
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
@swissspidy - Do I need to update anything else in this PR? |
No :) This just needs a review now, ideally from someone else than me. |
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.
Great, thanks for the quick response! Everything looks good to me
Fixes #120
Description
This PR enhances the wp db query command to return the number of rows affected for UPDATE and DELETE queries. Currently, the command only returns a success or failure message without specifying how many rows were impacted. This update aligns WP-CLI's behavior with MySQL, providing more transparency when executing data modifications.
Changes
Testing Instructions
wp db query "DELETE FROM wp_posts WHERE ID < 100;"
Success: Query succeeded. Rows affected: 15
Additional Notes
REC-20250225224011.mp4