Merge 'DBIx-Class-current' into 'storage_exceptions'
Brandon L. Black [Sun, 23 Jul 2006 16:27:54 +0000 (16:27 +0000)]
r6928@moloko (orig r2221):  ningu | 2006-07-20 17:02:09 -0500
fix oversight with source_name (regular accessor, not component_class)
r6929@moloko (orig r2222):  castaway | 2006-07-21 02:20:14 -0500
Minor fixes to deploy / sqltargs, and more glossary

r6930@moloko (orig r2223):  dsully | 2006-07-22 18:22:35 -0500
Avoid a FC5 performance hit by using a named hash and then blessing it.

r7341@moloko (orig r2597):  blblack | 2006-07-23 11:23:02 -0500
 r2074@moloko (orig r2072):  blblack | 2006-06-28 18:41:58 -0500
 creating column_info_from_storage branch
 r2075@moloko (orig r2073):  blblack | 2006-06-28 19:44:39 -0500
 turn off automatic columns_info_for by default.  Can be enabled per-source with __PACKAGE__->load_column_info_from_storage

lib/DBIx/Class/Manual/Glossary.pod
lib/DBIx/Class/ResultSet.pm
lib/DBIx/Class/ResultSource.pm
lib/DBIx/Class/ResultSourceProxy.pm
lib/DBIx/Class/Schema.pm
lib/DBIx/Class/Storage/DBI.pm
t/60core.t
t/72pg.t

index 3e9d36a..818e88a 100644 (file)
@@ -4,12 +4,38 @@ DBIx::Class::Manual::Glossary - Clarification of terms used.
 
 =head1 INTRODUCTION
 
-This document lists various terms used in DBIx::Class and attempts to explain them.
+This document lists various terms used in DBIx::Class and attempts to
+explain them.
 
 =head1 TERMS
 
+=head2 Inflation
+
+The act of turning database row data into objects in
+language-space. DBIx::Class further allows you to inflate your data
+into perl objects which more usefully represent their contents. For
+example: L<DBIx::Class::InflateColumn::DateTime> for datetime or
+timestamp column data.
+
+=head2 Join
+
+This is an SQL keyword that gets mentioned a lot. It is used to fetch
+data from more than one table at once, by C<join>ing the tables on
+fields where they have common data.
+
+=head2 Normalisation
+
+A normalised database is a sane database. Each table contains only
+data belonging to one concept, related tables refer to the key field
+or fields of each other. Some links to webpages about normalisation
+can be found in L<DBIx::Class::Manual::FAQ|the FAQ>.
+
 =head2 ORM
 
+Object-relational mapping, or Object-relationship modelling. Either
+way it's a method of mapping the contents of database tables (rows),
+to objects in programming-language-space. DBIx::Class is an ORM.
+
 =head2 ResultSet
 
 This is an object representing a set of data. It can either be an
index c71043b..39611eb 100644 (file)
@@ -95,14 +95,24 @@ sub new {
 
   $attrs->{alias} ||= 'me';
 
-  bless {
+  # XXXX
+  # Use a named hash here and bless afterwards to avoid a huge performance hit
+  # in perl 5.8.8-5+ FC5 and later, and possibly other distributions.
+  #
+  # See https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=196836 for more
+  # information.
+  my $self = {
     result_source => $source,
     result_class => $attrs->{result_class} || $source->result_class,
     cond => $attrs->{where},
     count => undef,
     pager => undef,
     attrs => $attrs
-  }, $class;
+  };
+
+  bless $self, $class;
+
+  return $self;
 }
 
 =head2 search
index 9fd7a2a..2b81444 100644 (file)
@@ -12,10 +12,10 @@ __PACKAGE__->load_components(qw/AccessorGroup/);
 
 __PACKAGE__->mk_group_accessors('simple' => qw/_ordered_columns
   _columns _primaries _unique_constraints name resultset_attributes
-  schema from _relationships/);
+  schema from _relationships column_info_from_storage source_name/);
 
 __PACKAGE__->mk_group_accessors('component_class' => qw/resultset_class
-  result_class source_name/);
+  result_class/);
 
 =head1 NAME
 
@@ -181,6 +181,7 @@ sub column_info {
     unless exists $self->_columns->{$column};
   #warn $self->{_columns_info_loaded}, "\n";
   if ( ! $self->_columns->{$column}{data_type}
+       and $self->column_info_from_storage
        and ! $self->{_columns_info_loaded}
        and $self->schema and $self->storage )
   {
@@ -201,6 +202,15 @@ sub column_info {
   return $self->_columns->{$column};
 }
 
+=head2 load_column_info_from_storage
+
+Enables the on-demand automatic loading of the above column
+metadata from storage as neccesary.
+
+=cut
+
+sub load_column_info_from_storage { shift->column_info_from_storage(1) }
+
 =head2 columns
 
   my @column_names = $obj->columns;
index f174d75..591927f 100644 (file)
@@ -35,6 +35,9 @@ sub column_info {
   return $self->result_source_instance->column_info($column);
 }
 
+sub load_column_info_from_storage {
+  shift->result_source_instance->load_column_info_from_storage;
+}
 
 sub columns {
   return shift->result_source_instance->columns(@_);
index 427faeb..47e78cf 100644 (file)
@@ -751,7 +751,7 @@ sub ddl_filename
     my ($self, $type, $dir, $version) = @_;
 
     my $filename = ref($self);
-    $filename =~ s/^.*:://;
+    $filename =~ s/::/-/;
     $filename = "$dir$filename-$version-$type.sql";
 
     return $filename;
index ed69f43..d615e2a 100644 (file)
@@ -1005,14 +1005,12 @@ sub create_ddl_dir
   $databases ||= ['MySQL', 'SQLite', 'PostgreSQL'];
   $databases = [ $databases ] if(ref($databases) ne 'ARRAY');
   $version ||= $schema->VERSION || '1.x';
+  $sqltargs = { ( add_drop_table => 1 ), %{$sqltargs || {}} };
 
   eval "use SQL::Translator";
   $self->throw_exception("Can't deploy without SQL::Translator: $@") if $@;
 
-  my $sqlt = SQL::Translator->new({
-#      debug => 1,
-      add_drop_table => 1,
-  });
+  my $sqlt = SQL::Translator->new($sqltargs);
   foreach my $db (@$databases)
   {
     $sqlt->reset();
@@ -1098,7 +1096,7 @@ L<DBIx::Class::Schema/deploy>.
 
 sub deploy {
   my ($self, $schema, $type, $sqltargs) = @_;
-  foreach my $statement ( $self->deployment_statements($schema, $type, undef, undef, { no_comments => 1, %$sqltargs }) ) {
+  foreach my $statement ( $self->deployment_statements($schema, $type, undef, undef, { no_comments => 1, %{ $sqltargs || {} } } ) ) {
     for ( split(";\n", $statement)) {
       next if($_ =~ /^--/);
       next if(!$_);
index aae959e..a468515 100644 (file)
@@ -277,6 +277,7 @@ ok(!$@, "stringify to false value doesn't cause error");
 # test column_info
 {
   $schema->source("Artist")->{_columns}{'artistid'} = {};
+  $schema->source("Artist")->load_column_info_from_storage;
 
   my $typeinfo = $schema->source("Artist")->column_info('artistid');
   is($typeinfo->{data_type}, 'INTEGER', 'column_info ok');
index f0bb3f8..f393a9a 100644 (file)
--- a/t/72pg.t
+++ b/t/72pg.t
@@ -15,6 +15,7 @@ use DBICTest;
   __PACKAGE__->load_components(qw/PK::Auto Core/);
   __PACKAGE__->table('casecheck');
   __PACKAGE__->add_columns(qw/id name NAME uc_name/);
+  __PACKAGE__->load_column_info_from_storage;
   __PACKAGE__->set_primary_key('id');
 
 }