Skip to content

Commit

Permalink
Merge pull request #267 from wp-cli/266-correct-error-message
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy authored Aug 13, 2024
2 parents 5cf12ef + 176dc75 commit 6c09f32
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions features/db-search.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1102,5 +1102,13 @@ Feature: Search through the database
And STDOUT should be empty
And the return code should be 1

When I try `wp db search example.com --format=count`
Then STDERR should be:
"""
Error: The "count" format can only be used for a single table.
"""
And STDOUT should be empty
And the return code should be 1

When I run `wp db search mail.example.com wp_options --format=ids`
Then STDOUT should not be empty
2 changes: 1 addition & 1 deletion src/DB_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -1553,7 +1553,7 @@ public function search( $args, $assoc_args ) {

if ( in_array( $format, [ 'ids', 'count' ], true ) ) {
if ( count( $tables ) > 1 ) {
WP_CLI::error( 'The "ids" format can only be used for a single table.' );
WP_CLI::error( "The \"{$format}\" format can only be used for a single table." );
}
$search_results = array_column( $search_results, 'primary_key_value' );
}
Expand Down

0 comments on commit 6c09f32

Please sign in to comment.