$self->_sql_maker_opts->{$sql_maker_opt} = $opt_val;
}
}
- for my $connect_do_opt (qw/on_connect_do on_disconnect_do/) {
- if(my $opt_val = delete $attrs{$connect_do_opt}) {
- $self->$connect_do_opt($opt_val);
- }
- }
}
%attrs = () if (ref $args[0] eq 'CODE'); # _connect() never looks past $args[0] in this case
=cut
sub _parse_connect_do {
- my ($self, $type, $val) = @_;
+ my ($self, $type) = @_;
+
+ my $val = $self->$type;
+ return () if not defined $val;
my @res;
} elsif (ref($val) eq 'CODE') {
push @res, $val;
} elsif (ref($val) eq 'ARRAY') {
- push @res, map [ 'do_sql', $_ ], @$val;
+ push @res, map { [ 'do_sql', $_ ] } @$val;
} else {
$self->throw_exception("Invalid type for $type: ".ref($val));
}
my ($self) = @_;
if( $self->connected ) {
- if (my $connection_call = $self->on_disconnect_call) {
- $self->_do_connection_actions(disconnect_call_ => $connection_call)
- }
- if (my $connection_do = $self->on_disconnect_do) {
- $self->_do_connection_actions(
- disconnect_call_ => $self->_parse_connect_do(
- on_disconnect_do => $connection_do
- )
- )
- }
+ my @actions;
+
+ push @actions, ( $self->on_disconnect_call || () );
+ push @actions, $self->_parse_connect_do ('on_disconnect_do');
+
+ $self->_do_connection_actions(disconnect_call_ => $_) for @actions;
$self->_dbh->rollback unless $self->_dbh_autocommit;
$self->_dbh->disconnect;
sub _sql_maker_args {
my ($self) = @_;
-
+
return ( bindtype=>'columns', array_datatypes => 1, limit_dialect => $self->dbh, %{$self->_sql_maker_opts} );
}
# there is no transaction in progress by definition
$self->{transaction_depth} = $self->_dbh_autocommit ? 0 : 1;
- if (my $connection_call = $self->on_connect_call) {
- $self->_do_connection_actions(connect_call_ => $connection_call)
- }
- if (my $connection_do = $self->on_connect_do) {
- $self->_do_connection_actions(
- connect_call_ => $self->_parse_connect_do(on_connect_do => $connection_do)
- )
- }
+ my @actions;
+
+ push @actions, ( $self->on_connect_call || () );
+ push @actions, $self->_parse_connect_do ('on_connect_do');
+
+ $self->_do_connection_actions(connect_call_ => $_) for @actions;
}
sub _determine_driver {