Skip to content

Commit

Permalink
chore: show create should print expand
Browse files Browse the repository at this point in the history
  • Loading branch information
TCeason committed Oct 14, 2024
1 parent c7beea0 commit ad7e290
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cli/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ impl<'a> FormatDisplay<'a> {
}

let schema = self.data.schema();
if self.kind == QueryKind::ShowCreate {
print_expanded(schema, &rows)?;
return Ok(());
}

match self.settings.expand {
ExpandMode::On => {
print_expanded(schema, &rows)?;
Expand Down Expand Up @@ -275,6 +280,7 @@ impl<'a> FormatDisplay<'a> {

let (rows, mut rows_str, kind, total_rows, total_bytes) = match self.kind {
QueryKind::Explain => (self.rows, "rows", "explain", 0, 0),
QueryKind::ShowCreate => (self.rows, "rows", "showcreate", 0, 0),
QueryKind::Query => (self.rows, "rows", "read", stats.read_rows, stats.read_bytes),
QueryKind::Update | QueryKind::AlterUserPassword => (
stats.write_rows,
Expand Down
6 changes: 6 additions & 0 deletions cli/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ pub enum QueryKind {
Put,
Get,
AlterUserPassword,
ShowCreate,
}

impl From<&str> for QueryKind {
Expand All @@ -633,6 +634,11 @@ impl From<&str> for QueryKind {
match tz.next() {
Some(Ok(t)) => match t.kind {
TokenKind::EXPLAIN => QueryKind::Explain,
TokenKind::SHOW => match tz.next() {
Some(Ok(t)) if t.kind == TokenKind::CREATE => QueryKind::ShowCreate,
_ => QueryKind::Query,
},

TokenKind::PUT => QueryKind::Put,
TokenKind::GET => QueryKind::Get,
TokenKind::ALTER => {
Expand Down

0 comments on commit ad7e290

Please sign in to comment.