Skip to content

Output only matching IDs in db search #158

Closed

Description

@johnbillion

When using the wp db search command to search only in a given table (eg. wp_posts), I'd like the output to only contain IDs so I can export them elsewhere without having to extract them from the results which include the matching strings and the context.

Approximately the closest I can get to this is:

wp db search foo wp_posts  --before_context=0 --after_context=0 --one_line

I'd like a flag for the opposite of --matches_only, probably --ids-only.

Activity

  1. added
    command:db
    good-first-issue
    command:db-search
    on Sep 8, 2023
  2. danielbachhuber commented on Sep 8, 2023

    @danielbachhuber
    Member

    This seems reasonable.

  3. changed the title [-]Output only matching IDs[/-] [+]Output only matching IDs in db search[/+] on Nov 4, 2023
  4. swissspidy commented on Nov 10, 2023

    @swissspidy
    Member

    We discussed this today during Hack Day. One suggestion to further enhance this is to leverage the formatter (--format) in a backward compatible manner. e.g. --format=ids or --format=matches (the default). The existing --matches_only arg could still be used, hence the backward compatibility.
    --format=ids with multiple tables doesn't really make sense, so this could be prevented with a warning/error.

  5. i-am-chitti commented on Apr 26, 2024

    @i-am-chitti

    @johnbillion @swissspidy Is it still open for working? I can work on this.

  6. swissspidy commented on Apr 26, 2024

    @swissspidy
    Member

    I think so yes :) Feel free to look into it

  7. johnbillion commented on Apr 26, 2024

    @johnbillion
    ContributorAuthor

    @i-am-chitti There's a PR at #247. If you'd like to review that it would be helpful. I'm about to take a look myself.

  8. added this to the 2.0.28 milestone on Apr 27, 2024
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

    command:dbcommand:db-searchcontributor-daygood-first-issue

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions