Merge 'trunk' into 'sybase'
Peter Rabbitson [Thu, 20 Aug 2009 07:49:05 +0000 (07:49 +0000)]
r7346@Thesaurus (orig r7343):  robkinyon | 2009-08-19 21:44:48 +0200
Applied doc patch by spb
r7347@Thesaurus (orig r7344):  ribasushi | 2009-08-20 07:50:49 +0200
Fix a weird-ass sqlt invocation in deployment_statements()
r7348@Thesaurus (orig r7345):  ribasushi | 2009-08-20 08:19:07 +0200
Apply pod patch by arthas (slightly modified)

1  2 
lib/DBIx/Class/Storage/DBI.pm
t/lib/sqlite.sql

@@@ -651,8 -651,7 +651,8 @@@ sub disconnect 
  
      $self->_do_connection_actions(disconnect_call_ => $_) for @actions;
  
 -    $self->_dbh->rollback unless $self->_dbh_autocommit;
 +    $self->_dbh_rollback unless $self->_dbh_autocommit;
 +
      $self->_dbh->disconnect;
      $self->_dbh(undef);
      $self->{_dbh_gen}++;
@@@ -1068,31 -1067,27 +1068,31 @@@ sub txn_begin 
    if($self->{transaction_depth} == 0) {
      $self->debugobj->txn_begin()
        if $self->debug;
 -
 -    # being here implies we have AutoCommit => 1
 -    # if the user is utilizing txn_do - good for
 -    # him, otherwise we need to ensure that the
 -    # $dbh is healthy on BEGIN
 -    my $dbh_method = $self->{_in_dbh_do} ? '_dbh' : 'dbh';
 -    $self->$dbh_method->begin_work;
 -
 -  } elsif ($self->auto_savepoint) {
 +    $self->_dbh_begin_work;
 +  }
 +  elsif ($self->auto_savepoint) {
      $self->svp_begin;
    }
    $self->{transaction_depth}++;
  }
  
 +sub _dbh_begin_work {
 +  my $self = shift;
 +  # being here implies we have AutoCommit => 1
 +  # if the user is utilizing txn_do - good for
 +  # him, otherwise we need to ensure that the
 +  # $dbh is healthy on BEGIN
 +  my $dbh_method = $self->{_in_dbh_do} ? '_dbh' : 'dbh';
 +  $self->$dbh_method->begin_work;
 +}
 +
  sub txn_commit {
    my $self = shift;
    if ($self->{transaction_depth} == 1) {
      my $dbh = $self->_dbh;
      $self->debugobj->txn_commit()
        if ($self->debug);
 -    $dbh->commit;
 +    $self->_dbh_commit;
      $self->{transaction_depth} = 0
        if $self->_dbh_autocommit;
    }
    }
  }
  
 +sub _dbh_commit {
 +  my $self = shift;
 +  $self->_dbh->commit;
 +}
 +
  sub txn_rollback {
    my $self = shift;
    my $dbh = $self->_dbh;
          if ($self->debug);
        $self->{transaction_depth} = 0
          if $self->_dbh_autocommit;
 -      $dbh->rollback;
 +      $self->_dbh_rollback;
      }
      elsif($self->{transaction_depth} > 1) {
        $self->{transaction_depth}--;
    }
  }
  
 +sub _dbh_rollback {
 +  my $self = shift;
 +  $self->_dbh->rollback;
 +}
 +
  # This used to be the top-half of _execute.  It was split out to make it
  #  easier to override in NoBindVars without duping the rest.  It takes up
  #  all of _execute's args, and emits $sql, @bind.
@@@ -1345,17 -1330,12 +1345,17 @@@ sub insert_bulk 
  }
  
  sub update {
 -  my $self = shift @_;
 -  my $source = shift @_;
 -  $self->_determine_driver;
 +  my ($self, $source, @args) = @_; 
 +
 +# redispatch to update method of storage we reblessed into, if necessary
 +  if (not $self->_driver_determined) {
 +    $self->_determine_driver;
 +    goto $self->can('update');
 +  }
 +
    my $bind_attributes = $self->source_bind_attributes($source);
  
 -  return $self->_execute('update' => [], $source, $bind_attributes, @_);
 +  return $self->_execute('update' => [], $source, $bind_attributes, @args);
  }
  
  
@@@ -1887,21 -1867,6 +1887,21 @@@ sub _subq_count_select 
    return @pcols ? \@pcols : [ 1 ];
  }
  
 +#
 +# Returns an ordered list of column names before they are used
 +# in a SELECT statement. By default simply returns the list
 +# passed in.
 +#
 +# This may be overridden in a specific storage when there are
 +# requirements such as moving BLOB columns to the end of the 
 +# SELECT list.
 +sub _order_select_columns {
 +  #my ($self, $source, $columns) = @_;
 +  return @{$_[2]};
 +}
 +
 +
 +
  
  sub source_bind_attributes {
    my ($self, $source) = @_;
@@@ -2338,18 -2303,18 +2338,18 @@@ sub deployment_statements 
        . $self->_check_sqlt_message . q{'})
            if !$self->_check_sqlt_version;
  
-   require SQL::Translator::Parser::DBIx::Class;
-   eval qq{use SQL::Translator::Producer::${type}};
-   $self->throw_exception($@) if $@;
    # sources needs to be a parser arg, but for simplicty allow at top level
    # coming in
    $sqltargs->{parser_args}{sources} = delete $sqltargs->{sources}
        if exists $sqltargs->{sources};
  
-   my $tr = SQL::Translator->new(%$sqltargs);
-   SQL::Translator::Parser::DBIx::Class::parse( $tr, $schema );
-   return "SQL::Translator::Producer::${type}"->can('produce')->($tr);
+   my $tr = SQL::Translator->new(
+     producer => "SQL::Translator::Producer::${type}",
+     %$sqltargs,
+     parser => 'SQL::Translator::Parser::DBIx::Class',
+     data => $schema,
+   );
+   return $tr->translate;
  }
  
  sub deploy {
diff --combined t/lib/sqlite.sql
@@@ -1,4 -1,6 +1,4 @@@
- -- Created on Wed Aug 12 16:10:43 2009
 --- 
 --- Created by SQL::Translator::Producer::SQLite
+ -- Created on Thu Aug 20 07:47:13 2009
  -- 
  
  
@@@ -14,6 -16,8 +14,8 @@@ CREATE TABLE artist 
    charfield char(10)
  );
  
+ CREATE INDEX artist_name_hookidx ON artist (name);
  --
  -- Table: bindtype_test
  --