Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output only matching IDs in db search #158

Closed
johnbillion opened this issue Jan 5, 2020 · 5 comments · Fixed by #247
Closed

Output only matching IDs in db search #158

johnbillion opened this issue Jan 5, 2020 · 5 comments · Fixed by #247

Comments

@johnbillion
Copy link
Contributor

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.

@danielbachhuber
Copy link
Member

This seems reasonable.

@danielbachhuber danielbachhuber changed the title Output only matching IDs Nov 4, 2023
@swissspidy
Copy link
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.

@i-am-chitti
Copy link

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

@swissspidy
Copy link
Member

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

@johnbillion
Copy link
Contributor Author

@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.

@danielbachhuber danielbachhuber added this to the 2.0.28 milestone Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment