Skip to content

Commit

Permalink
Cover all payloads on cli::print (#984)
Browse files Browse the repository at this point in the history
Print results of all Statements including DDL and TCL
It would be helpful to watch the progress of executing lots of sqls in file.
  • Loading branch information
devgony authored Nov 4, 2022
1 parent 6fe7445 commit d3d2a9d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion cli/src/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ impl<'a, W: Write> Print<W> {
};

match payload {
Payload::Create => self.write("Table created")?,
Payload::DropTable => self.write("Table dropped")?,
Payload::AlterTable => self.write("Table altered")?,
Payload::CreateIndex => self.write("Index created")?,
Payload::DropIndex => self.write("Index dropped")?,
Payload::Commit => self.write("Commit completed")?,
Payload::Rollback => self.write("Rollback completed")?,
Payload::StartTransaction => self.write("Transaction started")?,
Payload::Insert(n) => affected(*n, "inserted")?,
Payload::Delete(n) => affected(*n, "deleted")?,
Payload::Update(n) => affected(*n, "updated")?,
Expand Down Expand Up @@ -164,7 +172,6 @@ impl<'a, W: Write> Print<W> {
}
}
}
_ => {}
};

Ok(())
Expand Down Expand Up @@ -304,6 +311,14 @@ mod tests {
};
}

test!(&Payload::Create, "Table created");
test!(&Payload::DropTable, "Table dropped");
test!(&Payload::AlterTable, "Table altered");
test!(&Payload::CreateIndex, "Index created");
test!(&Payload::DropIndex, "Index dropped");
test!(&Payload::Commit, "Commit completed");
test!(&Payload::Rollback, "Rollback completed");
test!(&Payload::StartTransaction, "Transaction started");
test!(&Payload::Insert(0), "0 row inserted");
test!(&Payload::Insert(1), "1 row inserted");
test!(&Payload::Insert(7), "7 rows inserted");
Expand Down

0 comments on commit d3d2a9d

Please sign in to comment.