| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
cc @johnbillion since you were involved in the discussion about this, maybe you'd like to take a look as well |
Sorry, something went wrong.
There was a problem hiding this comment.
It'd be great to have a more detailed pull request description that describes what this pull request does, and how it changes the nature of the command.
Sorry, something went wrong.
| * | ||
| * [--one_line] | ||
| * : Place the 'table:column' output on the same line as the row id and match ('table:column:id:match'). Overrides --table_column_once. | ||
| * : Deprecated: use `--format` instead. Place the 'table:column' output on the same line as the row id and match ('table:column:id:match'). Overrides --table_column_once. |
There was a problem hiding this comment.
What argument should they use with --format?
Sorry, something went wrong.
| * | ||
| * [--matches_only] | ||
| * : Only output the string matches (including context). No 'table:column's or row ids are outputted. | ||
| * : Deprecated: use `--format` instead. Only output the string matches (including context). No 'table:column's or row ids are outputted. |
There was a problem hiding this comment.
What argument should they use with --format?
Sorry, something went wrong.
| * : Get a specific subset of the fields. | ||
| * | ||
| * [--format=<format>] | ||
| * : Render output in a particular format. |
There was a problem hiding this comment.
We should document supported --format=<format> options with YAML:
[--format=<format>] --- options: - TK ---
Sorry, something went wrong.
| * : Percent color code to use for the match (unless both before and after context are 0, when no color code is used). For a list of available percent color codes, see below. Default '%3%k' (black on a mustard background). | ||
| * | ||
| * [--fields=<fields>] | ||
| * : Get a specific subset of the fields. |
There was a problem hiding this comment.
What fields are supported here?
Sorry, something went wrong.
| 'table' => $table, | ||
| 'column' => $column, | ||
| 'key' => $primary_key, | ||
| 'ID' => $result->$primary_key, |
There was a problem hiding this comment.
Should this be 'value' instead of 'ID'? It seems a little bit weird to call this 'ID' when the primary key column could be called something else.
Sorry, something went wrong.
|
@2ndkauboy Are you planning to continue working on this, or should we close the PR for now? |
Sorry, something went wrong.
|
@danielbachhuber i was hoping to get feedback from @johnbillion about this new feature, since he opened the issue. |
Sorry, something went wrong.
|
I'll take a look! |
Sorry, something went wrong.
|
@2ndkauboy I agree that introducing a --format parameter here is a good idea. Daniel left some good feedback and I agree with all his points. Is this something you'd like to continue with? |
Sorry, something went wrong.
So you would also rename the ID to value? |
Sorry, something went wrong.
|
Would people understand that value is for the key column? +------------+--------------+-----------+-------+-----------------------------+ | table | column | key | value | match | +------------+--------------+-----------+-------+-----------------------------+ | wp_options | option_value | option_id | 1 | https://localhost:8889 | | wp_options | option_value | option_id | 2 | https://localhost:8889 | | wp_posts | guid | ID | 1 | https://localhost:8889/?p=1 | | wp_users | user_url | ID | 1 | https://localhost:8889 | +------------+--------------+-----------+-------+-----------------------------+ |
Sorry, something went wrong.
|
What's the command for that output? |
Sorry, something went wrong.
|
The command for the output above would be: wp db search https://localhost:8889 --format=table |
Sorry, something went wrong.
|
I think value is better than ID but overall that table isn't particularly clear. Perhaps the order of the columns should change to: column, match, key, value. If we didn't need to support output from multiple database tables we could skip the key column completely and use the key as the name for the value column. +------------+--------------+-----------+-----------------------------+ | table | column | option_id | match | +------------+--------------+-----------+-----------------------------+ | wp_options | option_value | 2 | https://localhost:8889 | +------------+--------------+-----------+-----------------------------+ +------------+--------------+-------+-----------------------------+ | table | column | ID | match | +------------+--------------+-------+-----------------------------+ | wp_posts | guid | 1 | https://localhost:8889/?p=1 | +------------+--------------+-------+-----------------------------+ |
Sorry, something went wrong.
By default, the wp db search command searches in all tables and outputs something like this: wp_comments:comment_author_email 244936:me@example.com wp_options:option_value 14:mail.example.com wp_options:option_value 15:login@example.com So this includes: table, column, primary key value, match. This is why decided to have all these columns as well. But then the "primary key value" column needed a headline/name, and since it could be different column names, I added that key column as well. If we allow searching all tables, which the command does by default, we cannot use the "primary key name" as the headline/name, since it's different names. We could just not have that column, but then we need another headline. Maybe something like pk? 🤔 |
Sorry, something went wrong.
|
Yeah. Perhaps primary_key_name and primary_key_value? It's very verbose but it's clear. |
Sorry, something went wrong.
|
I thought about that as well. How about pk_column or pk_key_name and pk_value? |
Sorry, something went wrong.
|
@johnbillion I've simulated some variant, which one would you pick? Only the primary key value1. Column pk+------------+--------------+----+-----------------------------+ | table | column | pk | match | +------------+--------------+----+-----------------------------+ | wp_options | option_value | 1 | https://localhost:8889 | | wp_options | option_value | 2 | https://localhost:8889 | | wp_posts | guid | 1 | https://localhost:8889/?p=1 | | wp_users | user_url | 1 | https://localhost:8889 | +------------+--------------+----+-----------------------------+ 2. Column value+------------+--------------+-----+-----------------------------+ | table | column | key | match | +------------+--------------+-----+-----------------------------+ | wp_options | option_value | 1 | https://localhost:8889 | | wp_options | option_value | 2 | https://localhost:8889 | | wp_posts | guid | 1 | https://localhost:8889/?p=1 | | wp_users | user_url | 1 | https://localhost:8889 | +------------+--------------+-----+-----------------------------+ 3. Column primary_key_value+------------+--------------+-------------------+-----------------------------+ | table | column | primary_key_value | match | +------------+--------------+-------------------+-----------------------------+ | wp_options | option_value | 1 | https://localhost:8889 | | wp_options | option_value | 2 | https://localhost:8889 | | wp_posts | guid | 1 | https://localhost:8889/?p=1 | | wp_users | user_url | 1 | https://localhost:8889 | +------------+--------------+-------------------+-----------------------------+ Primary key column name and value4. Columns key and value+------------+--------------+-----------+-------+-----------------------------+ | table | column | key | value | match | +------------+--------------+-----------+-------+-----------------------------+ | wp_options | option_value | option_id | 1 | https://localhost:8889 | | wp_options | option_value | option_id | 2 | https://localhost:8889 | | wp_posts | guid | ID | 1 | https://localhost:8889/?p=1 | | wp_users | user_url | ID | 1 | https://localhost:8889 | +------------+--------------+-----------+-------+-----------------------------+ 5. Columns pk_column and pk_value+------------+--------------+-----------+----------+-----------------------------+ | table | column | pk_column | pk_value | match | +------------+--------------+-----------+----------+-----------------------------+ | wp_options | option_value | option_id | 1 | https://localhost:8889 | | wp_options | option_value | option_id | 2 | https://localhost:8889 | | wp_posts | guid | ID | 1 | https://localhost:8889/?p=1 | | wp_users | user_url | ID | 1 | https://localhost:8889 | +------------+--------------+-----------+----------+-----------------------------+ 6. Columns pk_key_name and pk_value+------------+--------------+-------------+----------+-----------------------------+ | table | column | pk_key_name | pk_value | match | +------------+--------------+-------------+----------+-----------------------------+ | wp_options | option_value | option_id | 1 | https://localhost:8889 | | wp_options | option_value | option_id | 2 | https://localhost:8889 | | wp_posts | guid | ID | 1 | https://localhost:8889/?p=1 | | wp_users | user_url | ID | 1 | https://localhost:8889 | +------------+--------------+-------------+----------+-----------------------------+ 7. Columns priamry_key_*+------------+--------------+------------------+-------------------+-----------------------------+ | table | column | priamry_key_name | priamry_key_value | match | +------------+--------------+------------------+-------------------+-----------------------------+ | wp_options | option_value | option_id | 1 | https://localhost:8889 | | wp_options | option_value | option_id | 2 | https://localhost:8889 | | wp_posts | guid | ID | 1 | https://localhost:8889/?p=1 | | wp_users | user_url | ID | 1 | https://localhost:8889 | +------------+--------------+------------------+-------------------+-----------------------------+ Different order8. Columns pk_key_* and match_*+------------+-------------+----------+--------------+-----------------------------+ | table | pk_key_name | pk_value | match_column | match_value | +------------+-------------+----------+--------------+-----------------------------+ | wp_options | option_id | 1 | option_value | https://localhost:8889 | | wp_options | option_id | 2 | option_value | https://localhost:8889 | | wp_posts | ID | 1 | guid | https://localhost:8889/?p=1 | | wp_users | ID | 1 | user_url | https://localhost:8889 | +------------+-------------+----------+--------------+-----------------------------+ 9. Columns obj_id_* and match_*+------------+------------+--------+--------------+-----------------------------+ | table | obj_id_key | obj_id | match_column | match_value | +------------+------------+--------+--------------+-----------------------------+ | wp_options | option_id | 1 | option_value | https://localhost:8889 | | wp_options | option_id | 2 | option_value | https://localhost:8889 | | wp_posts | ID | 1 | guid | https://localhost:8889/?p=1 | | wp_users | ID | 1 | user_url | https://localhost:8889 | +------------+------------+--------+--------------+-----------------------------+ |
Sorry, something went wrong.
|
Let's go with this: +------------+--------------+-----------+------------------+-----------------------------+ | table | column | match | primary_key_name | primary_key_value | +------------+--------------+-----------+------------------+-----------------------------+ |
Sorry, something went wrong.
|
The result would look like this now: $wp db search admin --format=table
+-------------+---------------+-----------------------------------------------------------------------------------------------+------------------+-------------------+
| table | column | match | primary_key_name | primary_key_value |
+-------------+---------------+-----------------------------------------------------------------------------------------------+------------------+-------------------+
| wp_options | option_name | admin_email | option_id | 6 |
| wp_options | option_name | admin_email_lifespan | option_id | 280 |
| wp_options | option_value | a:5:{s:13:"administrator";a:2:{s:4:"name";s:13:"Administrator";s:12:"capabilities";a:61:{s:13 | option_id | 89 |
| wp_options | option_value | e notification of site activity via the admin toolbar and your Mobile devices.";s:4:" | option_id | 164 |
| wp_usermeta | meta_key | admin_color | umeta_id | 7 |
| wp_usermeta | meta_key | show_admin_bar_front | umeta_id | 9 |
| wp_usermeta | meta_value | admin | umeta_id | 1 |
| wp_usermeta | meta_value | a:1:{s:13:"administrator";b:1;} | umeta_id | 10 |
| wp_users | user_login | admin | ID | 1 |
| wp_users | user_nicename | admin | ID | 1 |
| wp_users | display_name | admin | ID | 1 |
+-------------+---------------+-----------------------------------------------------------------------------------------------+------------------+-------------------+
|
Sorry, something went wrong.
|
@2ndkauboy I think that looks good. What do you think? |
Sorry, something went wrong.
|
Let's merge it then :) After my updated tests run ;) |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks for your work on this, @2ndkauboy !
Sorry, something went wrong.
|
Updated at WP-CLI Hack Day April 2024 #5935 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Closes #158
Related wp-cli/wp-cli#5859