Created
February 2, 2018 12:41
-
-
Save bayashi/9e57147e49c0c6e595cbb39cb56c538e to your computer and use it in GitHub Desktop.
vertical explain table for DBIx::QueryLog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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