Merge 'trunk' into 'replication_dedux'
John Napiorkowski [Fri, 18 Jul 2008 13:19:10 +0000 (13:19 +0000)]
r15115@dev (orig r4575):  plu | 2008-07-15 03:36:20 -0500
Skip custom query sources

r15119@dev (orig r4579):  lukes | 2008-07-15 17:13:08 -0500
 r9099@luke-mbp (orig r4573):  lukes | 2008-07-14 13:11:13 +0100
 new branch
 r9100@luke-mbp (orig r4574):  lukes | 2008-07-14 15:01:50 +0100
 reordered methods of Versioned.pm and factored the initialisation stuff from upgrade to install
 r9128@luke-mbp (orig r4576):  lukes | 2008-07-15 23:07:38 +0100
 major versioning doc refactor
 r9129@luke-mbp (orig r4577):  lukes | 2008-07-15 23:11:10 +0100
 removed EXPERIMENTAL notices

r15120@dev (orig r4581):  ash | 2008-07-16 11:41:52 -0500
Update docs re txn_scope_guard
r15158@dev (orig r4590):  groditi | 2008-07-17 15:22:40 -0500
 r20694@martha (orig r4588):  groditi | 2008-07-16 16:17:07 -0400
 _is_deteministic_value

r15159@dev (orig r4591):  groditi | 2008-07-17 15:22:50 -0500
 r20836@martha (orig r4589):  groditi | 2008-07-17 16:21:07 -0400
 Changes and AUTHORS

1  2 
lib/DBIx/Class/Schema.pm
lib/DBIx/Class/Storage/DBI.pm
lib/SQL/Translator/Parser/DBIx/Class.pm

diff --combined lib/DBIx/Class/Schema.pm
@@@ -62,29 -62,6 +62,6 @@@ particular which module inherits off wh
  
  =head1 METHODS
  
- =head2 schema_version
- Returns the current schema class' $VERSION
- =cut
- sub schema_version {
-   my ($self) = @_;
-   my $class = ref($self)||$self;
-   # does -not- use $schema->VERSION
-   # since that varies in results depending on if version.pm is installed, and if
-   # so the perl or XS versions. If you want this to change, bug the version.pm
-   # author to make vpp and vxs behave the same.
-   my $version;
-   {
-     no strict 'refs';
-     $version = ${"${class}::VERSION"};
-   }
-   return $version;
- }
  =head2 register_class
  
  =over 4
@@@ -647,9 -624,9 +624,9 @@@ sub setup_connection_class 
  
  =over 4
  
 -=item Arguments: $storage_type
 +=item Arguments: $storage_type|{$storage_type, \%args}
  
 -=item Return Value: $storage_type
 +=item Return Value: $storage_type|{$storage_type, \%args}
  
  =back
  
@@@ -663,13 -640,6 +640,13 @@@ in cases where the appropriate subclas
  dealing with MSSQL via L<DBD::Sybase>, in which case you'd set it to
  C<::DBI::Sybase::MSSQL>.
  
 +If your storage type requires instantiation arguments, those are defined as a 
 +second argument in the form of a hashref and the entire value needs to be
 +wrapped into an arrayref or a hashref.  We support both types of refs here in
 +order to play nice with your Config::[class] or your choice.
 +
 +See L<DBIx::Class::Storage::DBI::Replicated> for an example of this.
 +
  =head2 connection
  
  =over 4
@@@ -692,33 -662,19 +669,33 @@@ or L<DBIx::Class::Storage> in general
  sub connection {
    my ($self, @info) = @_;
    return $self if !@info && $self->storage;
 -  my $storage_class = $self->storage_type;
 +  
 +  my ($storage_class, $args) = ref $self->storage_type ? 
 +    ($self->_normalize_storage_type($self->storage_type),{}) : ($self->storage_type, {});
 +    
    $storage_class = 'DBIx::Class::Storage'.$storage_class
      if $storage_class =~ m/^::/;
    eval "require ${storage_class};";
    $self->throw_exception(
      "No arguments to load_classes and couldn't load ${storage_class} ($@)"
    ) if $@;
 -  my $storage = $storage_class->new($self);
 +  my $storage = $storage_class->new($self=>$args);
    $storage->connect_info(\@info);
    $self->storage($storage);
    return $self;
  }
  
 +sub _normalize_storage_type {
 +  my ($self, $storage_type) = @_;
 +  if(ref $storage_type eq 'ARRAY') {
 +    return @$storage_type;
 +  } elsif(ref $storage_type eq 'HASH') {
 +    return %$storage_type;
 +  } else {
 +    $self->throw_exception('Unsupported REFTYPE given: '. ref $storage_type);
 +  }
 +}
 +
  =head2 connect
  
  =over 4
@@@ -765,9 -721,10 +742,10 @@@ sub txn_do 
    $self->storage->txn_do(@_);
  }
  
- =head2 txn_scope_guard
+ =head2 txn_scope_guard (EXPERIMENTAL)
  
- Runs C<txn_scope_guard> on the schema's storage.
+ Runs C<txn_scope_guard> on the schema's storage. See 
+ L<DBIx::Class::Storage/txn_scope_guard>.
  
  =cut
  
@@@ -1145,7 -1102,7 +1123,7 @@@ sub create_ddl_dir 
    $self->storage->create_ddl_dir($self, @_);
  }
  
- =head2 ddl_filename (EXPERIMENTAL)
+ =head2 ddl_filename
  
  =over 4
  
@@@ -1222,6 -1179,29 +1200,29 @@@ sub dclone 
    return Storable::dclone($obj);
  }
  
+ =head2 schema_version
+ Returns the current schema class' $VERSION
+ =cut
+ sub schema_version {
+   my ($self) = @_;
+   my $class = ref($self)||$self;
+   # does -not- use $schema->VERSION
+   # since that varies in results depending on if version.pm is installed, and if
+   # so the perl or XS versions. If you want this to change, bug the version.pm
+   # author to make vpp and vxs behave the same.
+   my $version;
+   {
+     no strict 'refs';
+     $version = ${"${class}::VERSION"};
+   }
+   return $version;
+ }
  1;
  
  =head1 AUTHORS
@@@ -1063,7 -1063,6 +1063,7 @@@ sub _query_start 
  
      if ( $self->debug ) {
          @bind = $self->_fix_bind_params(@bind);
 +        
          $self->debugobj->query_start( $sql, @bind );
      }
  }
@@@ -1631,9 -1630,6 +1631,6 @@@ sub deployment_statements 
    my $tr = SQL::Translator->new(%$sqltargs);
    SQL::Translator::Parser::DBIx::Class::parse( $tr, $schema );
    return "SQL::Translator::Producer::${type}"->can('produce')->($tr);
-   return;
  }
  
  sub deploy {
@@@ -1711,31 -1707,6 +1708,31 @@@ sub build_datetime_parser 
      }
  }
  
 +=head2 is_replicating
 +
 +A boolean that reports if a particular L<DBIx::Class::Storage::DBI> is set to
 +replicate from a master database.  Default is undef, which is the result
 +returned by databases that don't support replication.
 +
 +=cut
 +
 +sub is_replicating {
 +    return;
 +    
 +}
 +
 +=head2 lag_behind_master
 +
 +Returns a number that represents a certain amount of lag behind a master db
 +when a given storage is replicating.  The number is database dependent, but
 +starts at zero and increases with the amount of lag. Default in undef
 +
 +=cut
 +
 +sub lag_behind_master {
 +    return;
 +}
 +
  sub DESTROY {
    my $self = shift;
    return if !$self->_dbh;
@@@ -69,6 -69,9 +69,9 @@@ sub parse 
      foreach my $moniker (sort @monikers)
      {
          my $source = $dbicschema->source($moniker);
+         
+         # Skip custom query sources
+         next if ref($source->name);
  
          # Its possible to have multiple DBIC source using same table
          next if $seen_tables{$source->name}++;
              my $othertable = $source->related_source($rel);
              my $rel_table = $othertable->name;
  
 +            # Force the order of @cond to match the order of ->add_columns
 +            my $idx;
 +            my %other_columns_idx = map {'foreign.'.$_ => ++$idx } $othertable->columns;            
 +            my @cond = sort { $other_columns_idx{$a} cmp $other_columns_idx{$b} } keys(%{$rel_info->{cond}}); 
 +      
              # Get the key information, mapping off the foreign/self markers
 -            my @cond = keys(%{$rel_info->{cond}});
              my @refkeys = map {/^\w+\.(\w+)$/} @cond;
              my @keys = map {$rel_info->{cond}->{$_} =~ /^\w+\.(\w+)$/} @cond;