X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI.pm;h=0b244d4091ab7322439f7bc4ba3de92c65424071;hb=194311161bdbebd2402c457ded300fc83b773f02;hp=83de25230ffbe46466868d3087de900d41e53878;hpb=613f65e5493254510c8201119165bcb55291b516;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 83de252..0b244d4 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -11,6 +11,7 @@ use DBIx::Class::SQLAHacks; use DBIx::Class::Storage::DBI::Cursor; use DBIx::Class::Storage::Statistics; use Scalar::Util qw/blessed weaken/; +use List::Util(); __PACKAGE__->mk_group_accessors('simple' => qw/_connect_info _dbi_connect_info _dbh _sql_maker _sql_maker_opts @@ -614,15 +615,15 @@ sub _populate_dbh { my @info = @{$self->_dbi_connect_info || []}; $self->_dbh($self->_connect(@info)); + $self->_conn_pid($$); + $self->_conn_tid(threads->tid) if $INC{'threads.pm'}; + $self->_determine_driver; # Always set the transaction depth on connect, since # there is no transaction in progress by definition $self->{transaction_depth} = $self->_dbh_autocommit ? 0 : 1; - $self->_conn_pid($$); - $self->_conn_tid(threads->tid) if $INC{'threads.pm'}; - my $connection_do = $self->on_connect_do; $self->_do_connection_actions($connection_do) if $connection_do; } @@ -1143,6 +1144,7 @@ sub _per_row_update_delete { my $guard = $self->txn_scope_guard; my $subrs_cur = $rs->cursor; + my $row_cnt = '0E0'; while (my @pks = $subrs_cur->next) { my $cond; @@ -1155,11 +1157,13 @@ sub _per_row_update_delete { $op eq 'update' ? $values : (), $cond, ); + + $row_cnt++; } $guard->commit; - return 1; + return $row_cnt; } sub _select { @@ -1177,17 +1181,20 @@ sub _select_args { my $sql_maker = $self->sql_maker; $sql_maker->{for} = $for; - if (exists $attrs->{group_by} || $attrs->{having}) { + my @in_order_attrs = qw/group_by having _virtual_order_by/; + if (List::Util::first { exists $attrs->{$_} } (@in_order_attrs) ) { $order = { - group_by => $attrs->{group_by}, - having => $attrs->{having}, - ($order ? (order_by => $order) : ()) + ($order + ? (order_by => $order) + : () + ), + ( map { $_ => $attrs->{$_} } (@in_order_attrs) ) }; } my $bind_attrs = {}; ## Future support my @args = ('select', $attrs->{bind}, $ident, $bind_attrs, $select, $condition, $order); if ($attrs->{software_limit} || - $self->sql_maker->_default_limit_syntax eq "GenericSubQ") { + $sql_maker->_default_limit_syntax eq "GenericSubQ") { $attrs->{software_limit} = 1; } else { $self->throw_exception("rows attribute must be positive if present")