Skip to content

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

Closed

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

Activity

  1. swissspidy commented on Jul 14, 2025

    @swissspidy
    Member

    @mrsdizzie could this perhaps be related to the table formatting work on the php-cli-utils package?

  2. mrsdizzie commented on Jul 15, 2025

    @mrsdizzie
    Member

    It is actually from #277

    I'll try and look into that when I can (part of the problem is the particular tests for the query command don't require a table, so it didn't detect that the default changed).

  3. mrsdizzie commented on Jul 15, 2025

    @mrsdizzie
    Member

    A work around for now is to manually pass --table or -t which will be forwarded on to the MySQL command and print the table. Previously, MySQL / MariaDB did auto detection to see if printing to a terminal and added the table, but that stopped working due to the PR above (the table itself comes from MySQL not any of our code).

    Some thought would need to be given for a proper fix that retains the feature added above

  4. added a commit that references this issue on Jul 23, 2025
    4652005
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions