Skip to content

Giving multiple same arguments to mysqldump (via wp db export) only forwards the latest #289

Open

Description

@astappiev

Bug Report

Using the following example:

wp db export --ignore-table-data=database.wp_fc_campaign_emails --ignore-table-data=database.wp_fsmpt_email_logs --ignore-table-data=database.wp_fc_campaign_url_metrics export.sql

Only the value of --ignore-table-data=database.wp_fc_campaign_url_metrics is forwarded to mysqldump.

From the docs:

To specify more than one table to ignore, use the directive multiple times, once for each table. Each table must be specified with both database and table names. See also --no-data.

I expect the arguments are parsed, and duplicate keys are just overridden by each other, which is not expected in this scenario.

Activity

  1. changed the title [-]Multiple same arguments to mysqldump (via wp db export) only forwards the latest argument[/-] [+]Giving multiple same arguments to mysqldump (via wp db export) only forwards the latest[/+] on Jul 7, 2025
  2. mrsdizzie commented on Jul 23, 2025

    @mrsdizzie
    Member

    Yes, this is a limitation of using an associative array for arguments. We already have the --exclude_tables option for the same reason:

    $exclude_tables = Utils\get_flag_value( $assoc_args, 'exclude_tables' );
    if ( isset( $exclude_tables ) ) {
    $tables = explode( ',', trim( $assoc_args['exclude_tables'], ',' ) );
    unset( $assoc_args['exclude_tables'] );
    foreach ( $tables as $table ) {
    $command .= ' --ignore-table';
    $command .= ' %s';
    $command_esc_args[] = trim( DB_NAME . '.' . $table );
    }
    }

    So I suppose a similar --exclude_tables_data would be needed to support that using the current framework.

  3. astappiev commented on Jul 25, 2025

    @astappiev
    Author

    The problem is that --ignore-table-data is only supported by newer MariaDB server.
    Would it be an issue to add a command that is only supported by some servers? If not, I can submit a PR.

  4. SleeplessByte commented on Oct 12, 2026

    @SleeplessByte

    Given that there are multiple flags that are supposed to be passed in multiple times, would it not be better to addopt something like --ignore-table-data[]= and --ignore-table[]= (so generic []). In that case, split by a known delimiter (use , by default, hardcode anything that requires something else?).

    Then we don't need an extra cli flag for each option.

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