Update fbsql \d meta-command to show system tables

This commit is contained in:
Travis Turner 2023-04-07 12:31:52 -05:00
parent 8f4f602ed8
commit a68435faa6
No known key found for this signature in database
GPG key ID: 3FB5CF5C97A37B30
2 changed files with 26 additions and 4 deletions

View file

@ -364,7 +364,7 @@ Input/Output
\warn [-n] [STRING] write string to standard error (-n for no newline)
Informational
\d list tables
\d list tables, including system tables
\d NAME describe table
\dt list tables
\dv list views
@ -504,8 +504,17 @@ func (m *metaDescribe) execute(cmd *Command) (responseAction, error) {
switch len(m.args) {
case 0:
// Describe with no args should list all relations (tables, views,
// etc.). For now, we're just going to list the tables.
return newMetaListTables().execute(cmd)
// etc.). For now, we're just going to list the tables, including system
// tables.
qry := []queryPart{
newPartRaw("SHOW TABLES WITH SYSTEM"),
}
if err := cmd.executeAndWriteQuery(qry); err != nil {
return actionNone, errors.Wrap(err, "executing query")
}
return actionReset, nil
case 1:
// Describe with a single arg will assume the arg is a table name, so it

15
cli/testdata/table vendored
View file

@ -11,6 +11,19 @@ EXPECTCOMP:WithFormat:| fb_____________________ | fb_____________________ |
EXPECT:+-------------------------+-------------------------+-------+------------+----------------------+----------------------+-------+------------+-------------+
EXPECT:
// Show tables for database using \d.
SEND:\d
EXPECT:+-------------------------+-------------------------+-------+------------+----------------------+----------------------+-------+------------+-------------+
EXPECT:| _id | name | owner | updated_by | created_at | updated_at | keys | space_used | description |
EXPECT:+-------------------------+-------------------------+-------+------------+----------------------+----------------------+-------+------------+-------------+
EXPECTCOMP:WithFormat:| fb_____________________ | fb_____________________ | | | {timestamp} | {timestamp} | false | 0 | |
EXPECTCOMP:WithFormat:| fb_____________________ | fb_____________________ | | | {timestamp} | {timestamp} | false | 0 | |
EXPECTCOMP:WithFormat:| fb_____________________ | fb_____________________ | | | {timestamp} | {timestamp} | false | 0 | |
EXPECTCOMP:WithFormat:| fb_____________________ | fb_____________________ | | | {timestamp} | {timestamp} | false | 0 | |
EXPECTCOMP:WithFormat:| fb_____________________ | fb_____________________ | | | {timestamp} | {timestamp} | false | 0 | |
EXPECT:+-------------------------+-------------------------+-------+------------+----------------------+----------------------+-------+------------+-------------+
EXPECT:
// Show tables for database using SHOW TABLES.
SEND:SHOW TABLES;
EXPECT:+-----+------+-------+------------+------------+------------+------+------------+-------------+
@ -40,7 +53,7 @@ SEND:\dt
EXPECT:+-------+-------+-------+------------+----------------------+----------------------+-------+------------+-------------+
EXPECT:| _id | name | owner | updated_by | created_at | updated_at | keys | space_used | description |
EXPECT:+-------+-------+-------+------------+----------------------+----------------------+-------+------------+-------------+
EXPECTCOMP:WithFormat:| users | users | | | 1970-01-01T00:00:00Z | 1970-01-01T00:00:00Z | false | 0 | |
EXPECTCOMP:WithFormat:| users | users | | | {timestamp} | {timestamp} | false | 0 | |
EXPECT:+-------+-------+-------+------------+----------------------+----------------------+-------+------------+-------------+
EXPECT: