Merge 'trunk' into 'DBIx-Class-current'
Matt S Trout [Mon, 13 Nov 2006 08:35:04 +0000 (08:35 +0000)]
r33574@cain (orig r2868):  marcus | 2006-11-09 12:27:52 +0000
remove obsolete example.
r33576@cain (orig r2870):  matthewt | 2006-11-10 13:38:40 +0000
inflate_result can return an array now. somebody write me tests please
r33577@cain (orig r2871):  castaway | 2006-11-10 18:17:36 +0000
Documentation updates:
  add_columns column_info keys
  resultset_class example

r33593@cain (orig r2872):  castaway | 2006-11-10 22:22:22 +0000
Minor documentation update

r33596@cain (orig r2875):  matthewt | 2006-11-13 03:30:19 +0000
make multi-return actually work

Changes
lib/DBIx/Class/InflateColumn/DateTime.pm
lib/DBIx/Class/ResultSet.pm
lib/DBIx/Class/ResultSetManager.pm
lib/DBIx/Class/ResultSource.pm

diff --git a/Changes b/Changes
index d03b8ff..d93f058 100644 (file)
--- a/Changes
+++ b/Changes
@@ -18,6 +18,7 @@ Revision history for DBIx::Class
           __PACKAGE__->column_info_from_storage(1) for now
 
 0.07003 2006-XX-XX XX:XX:XX
+        - Tweaks to resultset to allow inflate_result to return an array
         - Fix UTF8Columns to work under Perl <= 5.8.0
         - Fix up new_result in ResultSet to avoid alias-related bugs
         - Made new/update/find handle 'single' rel accessor correctly
index f05523c..27ceaeb 100644 (file)
@@ -33,6 +33,8 @@ one your code should continue to work without modification (though note
 that this feature is new as of 0.07, so it may not be perfect yet - bug
 reports to the list very much welcome).
 
+For more help with components, see L<DBIx::Class::Manual::Component>.
+
 =cut
 
 __PACKAGE__->load_components(qw/InflateColumn/);
index 7e74edf..79d9cde 100644 (file)
@@ -536,7 +536,7 @@ sub single {
     $attrs->{where}, $attrs
   );
 
-  return (@data ? $self->_construct_object(@data) : ());
+  return (@data ? ($self->_construct_object(@data))[0] : ());
 }
 
 # _is_unique_query
@@ -721,22 +721,29 @@ sub next {
     $self->{all_cache_position} = 1;
     return ($self->all)[0];
   }
+  if ($self->{stashed_objects}) {
+    my $obj = shift(@{$self->{stashed_objects}});
+    delete $self->{stashed_objects} unless @{$self->{stashed_objects}};
+    return $obj;
+  }
   my @row = (
     exists $self->{stashed_row}
       ? @{delete $self->{stashed_row}}
       : $self->cursor->next
   );
   return unless (@row);
-  return $self->_construct_object(@row);
+  my ($row, @more) = $self->_construct_object(@row);
+  $self->{stashed_objects} = \@more if @more;
+  return $row;
 }
 
 sub _construct_object {
   my ($self, @row) = @_;
   my $info = $self->_collapse_result($self->{_attrs}{as}, \@row);
-  my $new = $self->result_class->inflate_result($self->result_source, @$info);
-  $new = $self->{_attrs}{record_filter}->($new)
+  my @new = $self->result_class->inflate_result($self->result_source, @$info);
+  @new = $self->{_attrs}{record_filter}->(@new)
     if exists $self->{_attrs}{record_filter};
-  return $new;
+  return @new;
 }
 
 sub _collapse_result {
index 46aa406..78461c9 100644 (file)
@@ -13,7 +13,6 @@ classes (EXPERIMENTAL)
 
   # in a table class
   __PACKAGE__->load_components(qw/ResultSetManager Core/); # note order!
-  __PACKAGE__->load_resultset_components(qw/AlwaysRS/);
 
   # will be removed from the table class and inserted into a
   # table-specific resultset class
@@ -68,10 +67,6 @@ sub table {
 
 =head2 load_resultset_components
 
-  # in a table class
-  __PACKAGE__->load_components(qw/ResultSetManager Core/); # note order!
-  __PACKAGE__->load_resultset_components(qw/AlwaysRS/);
-
 C<load_resultset_components> loads components in addition to
 C<DBIx::Class::ResultSet> (or whatever you set as
 C<base_resultset_class>).
index 14bc4f8..c585e19 100644 (file)
@@ -108,29 +108,31 @@ whatever your database supports.
 =item size
 
 The length of your column, if it is a column type that can have a size
-restriction. This is currently not used by DBIx::Class.
+restriction. This is currently only used by L<DBIx::Class::Schema/deploy>.
 
 =item is_nullable
 
 Set this to a true value for a columns that is allowed to contain
-NULL values. This is currently not used by DBIx::Class.
+NULL values. This is currently only used by L<DBIx::Class::Schema/deploy>.
 
 =item is_auto_increment
 
 Set this to a true value for a column whose value is somehow
 automatically set. This is used to determine which columns to empty
-when cloning objects using C<copy>.
+when cloning objects using C<copy>. It is also used by
+L<DBIx::Class::Schema/deploy>.
 
 =item is_foreign_key
 
 Set this to a true value for a column that contains a key from a
-foreign table. This is currently not used by DBIx::Class.
+foreign table. This is currently only used by
+L<DBIx::Class::Schema/deploy>.
 
 =item default_value
 
 Set this to the default value which will be inserted into a column
 by the database. Can contain either a value or a function. This is
-currently not used by DBIx::Class.
+currently only used by L<DBIx::Class::Schema/deploy>.
 
 =item sequence
 
@@ -139,6 +141,14 @@ generate a new key value. If not specified, L<DBIx::Class::PK::Auto>
 will attempt to retrieve the name of the sequence from the database
 automatically.
 
+=item extras
+
+This is used by L<DBIx::Class::Schema/deploy> and L<SQL::Translator>
+to add extra non-generic data to the column. For example: C<< extras
+=> { unsigned => 1} >> is used by the MySQL producer to set an integer
+column to unsigned. For more details, see
+L<SQL::Translator::Producer::MySQL>.
+
 =back
 
 =head2 add_column
@@ -931,12 +941,20 @@ but is cached from then on unless resultset_class changes.
 
 =head2 resultset_class
 
+` package My::ResultSetClass;
+  use base 'DBIx::Class::ResultSet';
+  ...
+
+  $source->resultset_class('My::ResultSet::Class');
+
 Set the class of the resultset, this is useful if you want to create your
 own resultset methods. Create your own class derived from
-L<DBIx::Class::ResultSet>, and set it here.
+L<DBIx::Class::ResultSet>, and set it here. 
 
 =head2 resultset_attributes
 
+  $source->resultset_attributes({ order_by => [ 'id' ] });
+
 Specify here any attributes you wish to pass to your specialised resultset.
 
 =cut