Skip Menu |

This queue is for tickets about the AnyEvent-DBI CPAN distribution.

Report information
The Basics
Id: 101241
Status: new
Priority: 0/
Queue: AnyEvent-DBI

People
Owner: MLEHMANN [...] cpan.org
Requestors: DEFCON [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: fetchall_arrayref argument support
Right now, the code will strictly only do a $sth->fetchall_arrayref . Instead, I'd rather it do $sth->fetchall_arrayref( {} ) . Possible interface of supporting this: my $dbh = AnyEvent::DBI->new( "DBI:SQLite:dbname=$filename", "", "", on_connect => sub { $cv->send }, fetch => sub { my ( $sth ) = @_; $sth->fetchall_arrayref( {} ) } ); Patch for this approach attached--it won't hurt my feelings if you don't accept it :). I had to use an ugly global variable since I don't have access to $self in the in the req_exec() method...
Subject: fetch.patch
--- DBI.pm 2013-04-01 22:13:03.000000000 -0400 +++ /Users/mrmccrac/lib/AnyEvent/DBI.pm 2015-01-01 23:11:30.000000000 -0500 @@ -81,6 +81,8 @@ our $DBH; +our $FETCH = sub { my $sth = shift; $sth->fetchall_arrayref }; + sub req_open { my (undef, $dbi, $user, $pass, %attr) = @{+shift}; @@ -91,13 +93,14 @@ sub req_exec { my (undef, $st, @args) = @{+shift}; + my $sth = $DBH->prepare_cached ($st, undef, 1) or die [$DBI::errstr]; my $rv = $sth->execute (@args) or die [$sth->errstr]; - [1, $sth->{NUM_OF_FIELDS} ? $sth->fetchall_arrayref : undef, $rv] + [1, $sth->{NUM_OF_FIELDS} ? $FETCH->($sth) : undef, $rv] } sub req_attr { @@ -284,19 +287,22 @@ Storable::thaw Storable::freeze []; sub new { + my ($class, $dbi, $user, $pass, %arg) = @_; my ($client, $server) = AnyEvent::Util::portable_socketpair or croak "unable to create AnyEvent::DBI communications pipe: $!"; my %dbi_args = %arg; - delete @dbi_args{qw(on_connect on_error timeout exec_server)}; + delete @dbi_args{qw(on_connect on_error timeout exec_server fetch)}; my $self = bless \%arg, $class; $self->{fh} = $client; AnyEvent::Util::fh_nonblocking $client, 1; + $FETCH = $self->{fetch} if $self->{fetch}; + my $rbuf; my @caller = (caller)[1,2]; # the "default" caller