Skip to content

wp db query no longer formats a table since 2.12.0 #290

@sun

Description

@sun

Bug Report

Up until version 2.11.0 on MacOS and Linux, wp db query renders a table output by default:

$ wp db query 'SELECT 1, 1, 1'
+---+---+---+
| 1 | 1 | 1 |
+---+---+---+
| 1 | 1 | 1 |
+---+---+---+

After updating to the 2.12.0, the output is no longer rendered as a table and I cannot find a flag to get a table output again:

$ wp cli update
You have version 2.11.0. Would you like to update to 2.12.0? [y/n] y
Downloading from https://github.com/wp-cli/wp-cli/releases/download/v2.12.0/wp-cli-2.12.0.phar...
md5 hash verified: a592bbf68fc5143bfad5800cb4947253
New version works. Proceeding to replace.
Success: Updated WP-CLI to 2.12.0.

$ wp db query 'SELECT 1, 1, 1'
1	1	1
1	1	1

When reverting back to 2.11.0, the table output works again:

$ wget -O ~/bin/wp https://github.com/wp-cli/wp-cli/releases/download/v2.11.0/wp-cli-2.11.0.phar
$ chmod +x ~/bin/wp
$ wp db query 'SELECT 1, 1, 1'
+---+---+---+
| 1 | 1 | 1 |
+---+---+---+
| 1 | 1 | 1 |
+---+---+---+

Expected behavior

  • wp db query should format the result as an ASCII table by default, as in previous versions.

Environment

OS:	Linux 5.15.0-131-generic #141-Ubuntu SMP Fri Jan 10 21:18:28 UTC 2025 x86_64
Shell:	/bin/bash
PHP binary:	/usr/bin/php8.0
PHP version:	8.0.30
php.ini used:	/etc/php/8.0/cli/php.ini
MySQL binary:	/usr/bin/mysql
MySQL version:	mysql  Ver 14.14 Distrib 5.7.42, for Linux (x86_64) using  EditLine wrapper
SQL modes:	ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	phar:///var/www/share/bin/wp
WP-CLI packages dir:	
WP-CLI cache dir:	/var/www/share/.wp-cli/cache
WP-CLI global config:	
WP-CLI project config:	/var/www/share/[redacted]/htdocs/wp-cli.yml
WP-CLI version:	2.12.0

Note: I tested with PHP 8.3, 8.1, and 8.0 to see whether there is a difference.

Details

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions