@@ -1,3 +1,5 @@
+0.34
+ - (EXPERIMENTAL) fix async select not getting err bug.
0.33
- (EXPERIMENTAL) fix MySQL async insert result.
0.32
@@ -1,6 +1,4 @@
Changes
-DBIx-Custom-0.31/META.json
-DBIx-Custom-0.31/META.yml
lib/DBIx/Custom.pm
lib/DBIx/Custom/Mapper.pm
lib/DBIx/Custom/Model.pm
@@ -108,7 +106,6 @@ t/common_uc/MyModel8/TABLE1.pm
t/common_uc/MyModel8/TABLE2.pm
t/create_fullqualified_module.pl
t/create_uppercase_module.pl
-t/mysql-async-opt-insert.t
t/mysql-async-opt.t
t/mysql-async.t
t/mysql.t
@@ -40,5 +40,5 @@
}
},
"release_status" : "stable",
- "version" : "0.33"
+ "version" : "0.34"
}
@@ -22,4 +22,4 @@ requires:
DBI: 1.605
Object::Simple: 3.1
Test::More: 0
-version: 0.33
+version: 0.34
@@ -40,5 +40,5 @@
}
},
"release_status" : "stable",
- "version" : "0.33"
+ "version" : "0.34"
}
@@ -22,4 +22,4 @@ requires:
DBI: 1.605
Object::Simple: 3.1
Test::More: 0
-version: 0.33
+version: 0.34
@@ -2,7 +2,7 @@ use 5.008007;
package DBIx::Custom;
use Object::Simple -base;
-our $VERSION = '0.33';
+our $VERSION = '0.34';
use Carp 'croak';
use DBI;
@@ -371,7 +371,7 @@ sub execute {
my $new_dbi = bless {%$self}, ref $self;
$new_dbi->connector(undef);
$new_dbi->{dbh} = DBI->connect($dsn, $user, $password,
- {%{$new_dbi->default_option}, %$option});
+ {%{$new_dbi->default_option}, %$option, PrintError => 0, RaiseError => 0});
$new_dbi->{_new_connection} = 1;
return $new_dbi->execute($sql, defined $params ? ($params) : (), %opt);
@@ -595,8 +595,6 @@ sub execute {
# Affected of insert, update, or delete
$self->last_sth($sth);
if (!$sth->{NUM_OF_FIELDS} && $opt{statement} ne 'select') {
- my $driver = $self->_driver;
-
# Non-Blocking
if (my $cb = $opt{async}) {
require AnyEvent;
@@ -606,6 +604,7 @@ sub execute {
poll => 'w',
cb => sub {
my $affected;
+ my $driver = $self->_driver;
if ($driver eq 'mysql') {
$affected = $sth->mysql_async_result;
}
@@ -656,6 +655,12 @@ sub execute {
fh => $self->async_conf->{fh}->($self),
poll => 'r',
cb => sub {
+ my $error;
+ my $driver = $self->_driver;
+ if ($driver eq 'mysql') {
+ $sth->mysql_async_result;
+ }
+
$cb->($self, $result);
undef $watcher;
undef $result;
@@ -1,61 +0,0 @@
-use Test::More;
-use strict;
-use warnings;
-use utf8;
-
-use FindBin;
-use DBIx::Custom;
-
-my $dbi;
-my $dsn;
-my $args;
-my $user = 'dbix_custom';
-my $password = 'dbix_custom';
-my $database = 'dbix_custom';
-
-$dsn = "dbi:mysql:database=$database";
-$args = {dsn => $dsn, user => $user, password => $password,};
-
-plan skip_all => 'mysql private test' unless -f "$FindBin::Bin/run/mysql-async-opt-insert.run"
- && eval { $dbi = DBIx::Custom->connect($args); 1 };
-plan 'no_plan';
-
-$SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /DEPRECATED/};
-
-# Function for test name
-sub test { print "# $_[0]\n" }
-
-$dbi = DBIx::Custom->connect(
- dsn => "dbi:mysql:database=$database;",
- user => $user,
- password => $password
-);
-
-eval { $dbi->do('drop table table1') };
-$dbi->do('create table table1 (key1 varchar(255), key2 varchar(255)) engine=InnoDB');
-
-test 'async test';
-
-require AnyEvent;
-
-my $cond = AnyEvent->condvar;
-
-$dbi->async_conf({
- prepare_attr => {async => 1},
- fh => sub { shift->dbh->mysql_fd }
-});
-
-$dbi->insert(
- {key1 => 1, key2 => 2},
- table => 'table1',
- async => sub {
- my ($dbi, $affected) = @_;
- is($affected, 1);
- $cond->send;
- }
-);
-
-$cond->recv;
-
-my $rows = $dbi->select(table => 'table1')->all;
-is_deeply($rows, [{key1 => 1, key2 => 2}]);
@@ -56,46 +56,104 @@ test 'async test';
require AnyEvent;
-my $cond = AnyEvent->condvar;
-
-my $timer = AnyEvent->timer(
- interval => 1,
- cb => sub {
- 1;
- }
-);
-
-my $count = 0;
-
$dbi->async_conf({
prepare_attr => {async => 1},
fh => sub { shift->dbh->mysql_fd }
});
-$dbi->execute('SELECT SLEEP(1), 3', undef,
- select => 1,
- async => sub {
- my ($dbi, $result) = @_;
- my $row = $result->fetch_one;
- is($row->[1], 3, 'before');
- $cond->send if ++$count == 2;
- }
-);
-
-$dbi->select('key1', table => 'table1',
- async => sub {
- my ($dbi, $result) = @_;
- my $row = $result->fetch_one;
- is($row->[0], 1, 'after1');
- $dbi->select('key1', table => 'table1',
- async => sub {
- my ($dbi, $result) = @_;
- my $row = $result->fetch_one;
- is($row->[0], 1, 'after2');
- $cond->send if ++$count == 2;
- }
- )
- }
-);
-
-$cond->recv;
+# Select
+{
+ my $cond = AnyEvent->condvar;
+
+ my $timer = AnyEvent->timer(
+ interval => 1,
+ cb => sub {
+ 1;
+ }
+ );
+
+ my $count = 0;
+
+ $dbi->execute('SELECT SLEEP(1), 3', undef,
+ select => 1,
+ async => sub {
+ my ($dbi, $result) = @_;
+ my $row = $result->fetch_one;
+ is($row->[1], 3, 'before');
+ ok(!$dbi->errstr);
+ $cond->send if ++$count == 2;
+ }
+ );
+
+ $dbi->select('key1', table => 'table1',
+ async => sub {
+ my ($dbi, $result) = @_;
+ my $row = $result->fetch_one;
+ is($row->[0], 1, 'after1');
+ $dbi->select('key1', table => 'table1',
+ async => sub {
+ my ($dbi, $result) = @_;
+ my $row = $result->fetch_one;
+ is($row->[0], 1, 'after2');
+ $cond->send if ++$count == 2;
+ }
+ )
+ }
+ );
+
+ $cond->recv;
+}
+
+# Select error
+{
+ my $cond = AnyEvent->condvar;
+ $dbi->select('key1', table => 'table_not_exists',
+ async => sub {
+ my ($dbi, $result) = @_;
+ ok($dbi->errstr);
+ $cond->send;
+ }
+ );
+
+ $cond->recv;
+}
+
+# insert
+{
+ $dbi->do('delete from table1');
+ my $cond = AnyEvent->condvar;
+
+ $dbi->insert(
+ {key1 => 1, key2 => 2},
+ table => 'table1',
+ async => sub {
+ my ($dbi, $affected) = @_;
+ is($affected, 1);
+ ok(!$dbi->errstr);
+ $cond->send;
+ }
+ );
+
+ $cond->recv;
+
+ my $rows = $dbi->select(table => 'table1')->all;
+ is_deeply($rows, [{key1 => 1, key2 => 2}]);
+}
+
+# insert error
+{
+ $dbi->do('delete from table1');
+ my $cond = AnyEvent->condvar;
+
+ $dbi->insert(
+ {key1 => 1, key2 => 2},
+ table => 'table_not_exists',
+ async => sub {
+ my ($dbi, $affected) = @_;
+ ok($dbi->errstr);
+ $cond->send;
+ }
+ );
+
+ $cond->recv;
+}