Skip to content

Instantly share code, notes, and snippets.

@bayashi
Created February 2, 2018 12:41
Show Gist options
  • Save bayashi/9e57147e49c0c6e595cbb39cb56c538e to your computer and use it in GitHub Desktop.
Save bayashi/9e57147e49c0c6e595cbb39cb56c538e to your computer and use it in GitHub Desktop.
vertical explain table for DBIx::QueryLog
return sub {
my %args = @_;
return $sth->fetchall_arrayref(+{}) unless defined $args{print} and $args{print};
my $t = Text::ASCIITable->new();
$t->setCols('explain', 'result');
$t->alignCol({explain => 'right', result => 'left'});
my @cols = @{$sth->{NAME}};
for my $records (@{$sth->fetchall_arrayref}) {
my $count = 0;
for my $value (@{$records}) {
$t->addRow([$cols[$count], defined($value) ? $value : 'NULL']);
$count++;
}
}
return $t;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment