diff --git a/features/db-columns.feature b/features/db-columns.feature index ba55cf6b..d6aa305b 100644 --- a/features/db-columns.feature +++ b/features/db-columns.feature @@ -41,7 +41,6 @@ Feature: Display information about a given table. Couldn't find any tables matching: wp_foobar """ - @require-mysql-or-mariadb Scenario: Display information about a non default WordPress table Given a WP install And I run `wp db query "CREATE TABLE not_wp ( date DATE NOT NULL, awesome_stuff TEXT, PRIMARY KEY (date) );;"` @@ -51,14 +50,3 @@ Feature: Display information about a given table. | Field | Type | Null | Key | Default | Extra | | date | date | NO | PRI | | | | awesome_stuff | text | YES | | | | - - @require-sqlite - Scenario: Display information about a non default WordPress table - Given a WP install - And I run `wp db query "CREATE TABLE not_wp ( date DATE NOT NULL, awesome_stuff TEXT, PRIMARY KEY (date) );;"` - - When I try `wp db columns not_wp` - Then STDOUT should be a table containing rows: - | Field | Type | Null | Key | Default | - | date | TEXT | NO | PRI | '' | - | awesome_stuff | TEXT | YES | | | diff --git a/features/db-tables.feature b/features/db-tables.feature index cb3f6810..98209eb2 100644 --- a/features/db-tables.feature +++ b/features/db-tables.feature @@ -1,6 +1,5 @@ Feature: List database tables - @require-mysql-or-mariadb Scenario: List database tables on a single WordPress install Given a WP install @@ -36,40 +35,7 @@ Feature: List database tables wp_postmeta,wp_posts """ - @require-sqlite - Scenario: List database tables on a single WordPress install - Given a WP install - - When I run `wp db tables` - Then STDOUT should contain: - """ - wp_users - wp_usermeta - wp_termmeta - wp_terms - wp_term_taxonomy - wp_term_relationships - wp_commentmeta - wp_comments - wp_links - wp_options - wp_postmeta - wp_posts - """ - - When I run `wp db tables --format=csv` - Then STDOUT should contain: - """ - ,wp_commentmeta,wp_comments, - """ - - When I run `wp db tables 'wp_post*' --format=csv` - Then STDOUT should be: - """ - wp_postmeta,wp_posts - """ - - @require-wp-3.9 @require-mysql-or-mariadb + @require-wp-3.9 Scenario: List database tables on a multisite WordPress install Given a WP multisite install @@ -153,84 +119,6 @@ Feature: List database tables wp_posts """ - @require-sqlite - Scenario: List database tables on a multisite WordPress install - Given a WP multisite install - - When I run `wp db tables` - Then STDOUT should contain: - """ - wp_users - wp_usermeta - wp_termmeta - wp_terms - wp_term_taxonomy - wp_term_relationships - wp_commentmeta - wp_comments - wp_links - wp_options - wp_postmeta - wp_posts - wp_blogs - wp_blogmeta - wp_registration_log - wp_site - wp_sitemeta - wp_signups - """ - - When I run `wp site create --slug=foo` - And I run `wp db tables --url=example.com/foo` - Then STDOUT should contain: - """ - wp_users - """ - And STDOUT should contain: - """ - wp_usermeta - """ - And STDOUT should contain: - """ - wp_2_posts - """ - - When I run `wp db tables --url=example.com/foo --scope=global` - Then STDOUT should not contain: - """ - wp_2_posts - """ - - When I run `wp db tables --all-tables-with-prefix` - Then STDOUT should contain: - """ - wp_2_posts - """ - And STDOUT should contain: - """ - wp_posts - """ - - When I run `wp db tables --url=example.com/foo --all-tables-with-prefix` - Then STDOUT should contain: - """ - wp_2_posts - """ - And STDOUT should not contain: - """ - wp_posts - """ - - When I run `wp db tables --url=example.com/foo --network` - Then STDOUT should contain: - """ - wp_2_posts - """ - And STDOUT should contain: - """ - wp_posts - """ - # AUTO_INCREMENT doesn't work with SQLite. @require-mysql-or-mariadb Scenario: Listing a site's tables should only list that site's tables diff --git a/src/DB_Command.php b/src/DB_Command.php index be9f14fc..a82392dd 100644 --- a/src/DB_Command.php +++ b/src/DB_Command.php @@ -1942,10 +1942,6 @@ public function columns( $args, $assoc_args ) { $formatter_fields = [ 'Field', 'Type', 'Null', 'Key', 'Default', 'Extra' ]; - if ( $this->is_sqlite() ) { - $formatter_fields = [ 'Field', 'Type', 'Null', 'Key', 'Default' ]; - } - $formatter_args = [ 'format' => $format, ]; diff --git a/src/DB_Command_SQLite.php b/src/DB_Command_SQLite.php index 6a7c107f..120819b5 100644 --- a/src/DB_Command_SQLite.php +++ b/src/DB_Command_SQLite.php @@ -221,6 +221,19 @@ protected function sqlite_query( $query, $assoc_args = [] ) { WP_CLI::error( 'SQLite database not available.' ); } + /* + * Strip redundant trailing semicolons and whitespace. + * + * The MySQL client silently ignores the empty statements they produce, + * whereas the SQLite drop-in parses them as a multi-query and bails out + * with "Multi-query is not supported.". Trim them for parity. + */ + $query = rtrim( $query, "; \t\n\r\0\x0B" ); + + if ( '' === $query ) { + WP_CLI::error( 'No query specified.' ); + } + $skip_column_names = Utils\get_flag_value( $assoc_args, 'skip-column-names', false ); try {