Skip to content

Commit 7ffdd82

Browse files
authored
Merge pull request #118 from austinginder/107-consistent-db-label
Fix issue #107
2 parents 5a239dc + efca712 commit 7ffdd82

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

features/db-size.feature

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,23 @@ Feature: Display database size
8383

8484
When I run `wp db size --size_format=TB`
8585
Then STDOUT should be a number
86+
87+
Scenario: Display database size in bytes with specific format for a WordPress install
88+
Given a WP install
89+
90+
When I run `wp db size --size_format=b --format=csv`
91+
Then STDOUT should contain:
92+
"""
93+
Name,Size
94+
wp_cli_test,"
95+
"""
96+
97+
But STDOUT should not be a number
98+
99+
When I run `wp db size --size_format=b --format=json`
100+
Then STDOUT should contain:
101+
"""
102+
[{"Name":"wp_cli_test","Size":"
103+
"""
104+
105+
But STDOUT should not be a number

src/DB_Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ public function size( $args, $assoc_args ) {
864864
}
865865
}
866866

867-
if ( ! empty( $size_format) && ! $tables ) {
867+
if ( ! empty( $size_format) && ! $tables && ! $format ) {
868868
WP_CLI::Line( filter_var( $rows[0]['Size'], FILTER_SANITIZE_NUMBER_INT ) );
869869
} else {
870870
// Display the rows.

0 commit comments

Comments
 (0)