Skip to content

Commit 98ef8f9

Browse files
authored
Merge pull request #210 from janw-me/master
2 parents ca8894a + 325a82d commit 98ef8f9

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

features/db-columns.feature

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,13 @@ Feature: Display information about a given table.
4040
"""
4141
Couldn't find any tables matching: wp_foobar
4242
"""
43+
44+
Scenario: Display information about a non default WordPress table
45+
Given a WP install
46+
And I run `wp db query "CREATE TABLE not_wp ( date DATE NOT NULL, awesome_stuff TEXT, PRIMARY KEY (date) );;"`
47+
48+
When I try `wp db columns not_wp`
49+
Then STDOUT should be a table containing rows:
50+
| Field | Type | Null | Key | Default | Extra |
51+
| date | date | NO | PRI | | |
52+
| awesome_stuff | text | YES | | | |

src/DB_Command.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@ public function search( $args, $assoc_args ) {
14611461
*
14621462
* ## OPTIONS
14631463
*
1464-
* [<table>]
1464+
* <table>
14651465
* : Name of the database table.
14661466
*
14671467
* [--format]
@@ -1513,7 +1513,7 @@ public function columns( $args, $assoc_args ) {
15131513

15141514
$format = Utils\get_flag_value( $assoc_args, 'format' );
15151515

1516-
Utils\wp_get_table_names( [ $args[0] ], [] );
1516+
Utils\wp_get_table_names( [ $args[0] ], [ 'all-tables' => true ] );
15171517

15181518
$columns = $wpdb->get_results(
15191519
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Asserted to be a valid table name through wp_get_table_names.

0 commit comments

Comments
 (0)