Merge 'DBIx-Class-current' into 'versioning'
Matt S Trout [Mon, 20 Nov 2006 19:14:56 +0000 (19:14 +0000)]
r33594@cain (orig r2873):  ash | 2006-11-12 16:52:21 +0000
Moved from M::B to M::I
Added myself to CONTRIBUTORS

r33595@cain (orig r2874):  ash | 2006-11-12 16:59:23 +0000
use inc::Module::Install 0.64 (no version previouly)

r33608@cain (orig r2876):  matthewt | 2006-11-13 08:35:04 +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

r33840@cain (orig r2899):  bricas | 2006-11-16 15:47:06 +0000
 r14845@Brian (orig r2878):  ash | 2006-11-13 15:48:13 -0400
 Seperated out quote tests so that matt can use them for S::A at some point (old
 test t/19quotes.t) Also includes two failing tests (quoted order by and
 { select => ['me.*']} attrs).

 r14870@Brian (orig r2882):  blblack | 2006-11-15 10:13:44 -0400
 fix for rt.cpan.org #22740 (use $^X instead of hardcoded "perl")
 r14875@Brian (orig r2887):  castaway | 2006-11-15 10:26:47 -0400
 Fix foreign/self example

 r14885@Brian (orig r2897):  blblack | 2006-11-15 16:16:14 -0400

 Don't blow up if columns_info_for returns useless results

 r14893@Brian (orig r2898):  bricas | 2006-11-16 11:42:33 -0400
 moving it to -current branch

r33841@cain (orig r2900):  bricas | 2006-11-16 15:48:02 +0000
moved from trunk
r33850@cain (orig r2909):  ash | 2006-11-18 01:13:36 +0000
Removed Class::Data::Accessor and DBIx::Class::AccessorGrouped and
replaced with Class::Accessor::Grouped.

component_class type accessors now just inherited and so no longer
automatcally require classes when set (noted in changes)

Added auto_install to Makefile.PL

r33996@cain (orig r2911):  matthewt | 2006-11-20 19:11:15 +0000
 r33842@cain (orig r2901):  bricas | 2006-11-16 15:54:41 +0000
 bumped ver. added some stuff to Changes i know were missing.
 r33845@cain (orig r2904):  blblack | 2006-11-16 16:43:42 +0000
 added changes entry for rt#22740
 r33846@cain (orig r2905):  castaway | 2006-11-16 16:45:29 +0000
 Added patch from Ted Carnahan to rel docs

18 files changed:
Build.PL
Changes
MANIFEST.SKIP
Makefile.PL
lib/DBIx/Class.pm
lib/DBIx/Class/AccessorGroup.pm [deleted file]
lib/DBIx/Class/Core.pm
lib/DBIx/Class/InflateColumn/DateTime.pm
lib/DBIx/Class/Relationship.pm
lib/DBIx/Class/ResultSet.pm
lib/DBIx/Class/ResultSetManager.pm
lib/DBIx/Class/ResultSource.pm
lib/DBIx/Class/ResultSourceProxy/Table.pm
lib/DBIx/Class/Row.pm
lib/DBIx/Class/Storage.pm
lib/DBIx/Class/Storage/Statistics.pm
t/89dbicadmin.t
t/95sql_maker_quote.t [new file with mode: 0644]

index 2ba9d22..a919ccc 100644 (file)
--- a/Build.PL
+++ b/Build.PL
@@ -1,32 +1,3 @@
-use strict;
-use Module::Build;
-
-my %arguments = (
-    create_makefile_pl => 'passthrough',
-    license            => 'perl',
-    module_name        => 'DBIx::Class',
-    requires           => {
-        'Cwd'                       => 3.19,
-        'Data::Page'                => 2.00,
-        'Scalar::Util'              => 0,
-        'SQL::Abstract'             => 1.20,
-        'SQL::Abstract::Limit'      => 0.101,
-        'Class::C3'                 => 0.13,
-        'Storable'                  => 0,
-        'Class::Data::Accessor'     => 0.01,
-       'Carp::Clan'                => 0,
-        'DBI'                       => 1.40,
-        'Module::Find'              => 0,
-        'Class::Inspector'          => 0,
-    },
-    build_requires      => {
-        'DBD::SQLite'               => 1.11,
-    },
-    create_makefile_pl => 'passthrough',
-    create_readme      => 1,
-    test_files         => [ glob('t/*.t'), glob('t/*/*.t') ],
-    script_files       => [ glob('script/*') ],
-);
-
-Module::Build->new(%arguments)->create_build_script;
-
+# Dear Distribution Packager. This use of require is intentional.
+# Module::Install detects Build.PL usage and acts accordingly.
+require 'Makefile.PL';
diff --git a/Changes b/Changes
index d03b8ff..913819d 100644 (file)
--- a/Changes
+++ b/Changes
@@ -16,12 +16,22 @@ Revision history for DBIx::Class
         - columns_info_for is deprecated, and no longer runs automatically.
           You can make it work like before via
           __PACKAGE__->column_info_from_storage(1) for now
-
-0.07003 2006-XX-XX XX:XX:XX
+        - Replaced DBIx::Class::AccessorGroup and Class::Data::Accessor with
+          Class::Accessor::Grouped. Only user noticible change is to 
+          table_class on ResultSourceProxy::Table (i.e. table objects in 
+          schemas) and, resultset_class and result_class in ResultSource. 
+          These accessors no longer automatically require the classes when
+          set.
+
+0.07003 2006-11-16 11:52:00
+        - fix for rt.cpan.org #22740 (use $^X instead of hardcoded "perl")
+        - 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
         - Fix NoBindVars to be safer and handle non-true bind values
+        - Don't blow up if columns_info_for returns useless results
+        - Documentation updates
 
 0.07002 2006-09-14 21:17:32
         - fix quote tests for recent versions of SQLite
index 10c77a4..9184f2a 100644 (file)
@@ -25,6 +25,7 @@
 \.tmp$
 \.old$
 \.bak$
+\..*?\.sw[po]$
 \#$
 \b\.#
 
@@ -39,3 +40,6 @@
 
 # Skip maint stuff
 ^maint/
+
+# Dont use Module::Build anymore
+# Build.PL
index 192903a..d8f960e 100644 (file)
@@ -1,31 +1,31 @@
-# Note: this file was auto-generated by Module::Build::Compat version 0.03
-    
-    unless (eval "use Module::Build::Compat 0.02; 1" ) {
-      print "This module requires Module::Build to install itself.\n";
-      
-      require ExtUtils::MakeMaker;
-      my $yn = ExtUtils::MakeMaker::prompt
-       ('  Install Module::Build now from CPAN?', 'y');
-      
-      unless ($yn =~ /^y/i) {
-       die " *** Cannot install without Module::Build.  Exiting ...\n";
-      }
-      
-      require Cwd;
-      require File::Spec;
-      require CPAN;
-      
-      # Save this 'cause CPAN will chdir all over the place.
-      my $cwd = Cwd::cwd();
-      
-      CPAN::Shell->install('Module::Build::Compat');
-      CPAN::Shell->expand("Module", "Module::Build::Compat")->uptodate
-       or die "Couldn't install Module::Build, giving up.\n";
-      
-      chdir $cwd or die "Cannot chdir() back to $cwd: $!";
-    }
-    eval "use Module::Build::Compat 0.02; 1" or die $@;
-    
-    Module::Build::Compat->run_build_pl(args => \@ARGV);
-    require Module::Build;
-    Module::Build::Compat->write_makefile(build_class => 'Module::Build');
+use inc::Module::Install 0.64;
+
+name     'DBIx-Class';
+all_from 'lib/DBIx/Class.pm';
+perl_version '5.006001';
+
+requires 'Cwd'                       => 3.19; 
+requires 'Data::Page'                => 2.00;
+requires 'Scalar::Util'              => 0;
+requires 'SQL::Abstract'             => 1.20;
+requires 'SQL::Abstract::Limit'      => 0.101;
+requires 'Class::C3'                 => 0.13;
+requires 'Storable'                  => 0;
+requires 'Carp::Clan'                => 0;
+requires 'DBI'                       => 1.40;
+requires 'Module::Find'              => 0;
+requires 'Class::Inspector'          => 0;
+requires 'Class::Accessor::Grouped'  => 0;
+
+# Perl 5.8.0 doesn't have utf8::is_utf8()
+requires 'Encode'                    => 0 if ($] <= 5.008000);  
+
+build_requires 'DBD::SQLite'         => 1.11;
+
+install_script 'script/dbicadmin';
+
+tests "t/*.t t/*/*.t";
+
+auto_install;
+
+WriteAll;
index 89a97bb..6d75377 100644 (file)
@@ -4,9 +4,14 @@ use strict;
 use warnings;
 
 use vars qw($VERSION);
-use base qw/DBIx::Class::Componentised Class::Data::Accessor/;
+use base qw/DBIx::Class::Componentised Class::Accessor::Grouped/;
+
+sub mk_classdata { 
+    my $self = shift;
+    $self->mk_group_accessors('inherited', $_[0]); 
+    $self->set_inherited(@_) if @_ > 1;
+}
 
-sub mk_classdata { shift->mk_classaccessor(@_); }
 sub component_base_class { 'DBIx::Class' }
 
 # Always remember to do all digits for the version even if they're 0
@@ -180,6 +185,8 @@ andyg: Andy Grundman <andy@hybridized.org>
 
 ank: Andres Kievsky
 
+ash: Ash Berlin <ash@cpan.org>
+
 blblack: Brandon L. Black <blblack@gmail.com>
 
 bluefeet: Aran Deltac <bluefeet@cpan.org>
diff --git a/lib/DBIx/Class/AccessorGroup.pm b/lib/DBIx/Class/AccessorGroup.pm
deleted file mode 100644 (file)
index 56bcf1b..0000000
+++ /dev/null
@@ -1,342 +0,0 @@
-package DBIx::Class::AccessorGroup;
-
-use strict;
-use warnings;
-
-use Carp::Clan qw/^DBIx::Class/;
-
-=head1 NAME
-
-DBIx::Class::AccessorGroup -  Lets you build groups of accessors
-
-=head1 SYNOPSIS
-
-=head1 DESCRIPTION
-
-This class lets you build groups of accessors that will call different
-getters and setters.
-
-=head1 METHODS
-
-=head2 mk_group_accessors
-
-=over 4
-
-=item Arguments: $group, @fieldspec
-
-Returns: none
-
-=back
-
-Creates a set of accessors in a given group.
-
-$group is the name of the accessor group for the generated accessors; they
-will call get_$group($field) on get and set_$group($field, $value) on set.
-
-@fieldspec is a list of field/accessor names; if a fieldspec is a scalar
-this is used as both field and accessor name, if a listref it is expected to
-be of the form [ $accessor, $field ].
-
-=cut
-
-sub mk_group_accessors {
-  my ($self, $group, @fields) = @_;
-
-  $self->_mk_group_accessors('make_group_accessor', $group, @fields);
-  return;
-}
-
-
-{
-    no strict 'refs';
-    no warnings 'redefine';
-
-    sub _mk_group_accessors {
-        my($self, $maker, $group, @fields) = @_;
-        my $class = ref $self || $self;
-
-        # So we don't have to do lots of lookups inside the loop.
-        $maker = $self->can($maker) unless ref $maker;
-
-        foreach my $field (@fields) {
-            if( $field eq 'DESTROY' ) {
-                carp("Having a data accessor named DESTROY  in ".
-                             "'$class' is unwise.");
-            }
-
-            my $name = $field;
-
-            ($name, $field) = @$field if ref $field;
-
-            my $accessor = $self->$maker($group, $field);
-            my $alias = "_${name}_accessor";
-
-            #warn "$class $group $field $alias";
-
-            *{$class."\:\:$name"}  = $accessor;
-              #unless defined &{$class."\:\:$field"}
-
-            *{$class."\:\:$alias"}  = $accessor;
-              #unless defined &{$class."\:\:$alias"}
-        }
-    }
-}
-
-=head2 mk_group_ro_accessors
-
-=over 4
-
-=item Arguments: $group, @fieldspec
-
-Returns: none
-
-=back
-
-Creates a set of read only accessors in a given group. Identical to
-<L:/mk_group_accessors> but accessors will throw an error if passed a value
-rather than setting the value.
-
-=cut
-
-sub mk_group_ro_accessors {
-    my($self, $group, @fields) = @_;
-
-    $self->_mk_group_accessors('make_group_ro_accessor', $group, @fields);
-}
-
-=head2 mk_group_wo_accessors
-
-=over 4
-
-=item Arguments: $group, @fieldspec
-
-Returns: none
-
-=back
-
-Creates a set of write only accessors in a given group. Identical to
-<L:/mk_group_accessors> but accessors will throw an error if not passed a
-value rather than getting the value.
-
-=cut
-
-sub mk_group_wo_accessors {
-    my($self, $group, @fields) = @_;
-
-    $self->_mk_group_accessors('make_group_wo_accessor', $group, @fields);
-}
-
-=head2 make_group_accessor
-
-=over 4
-
-=item Arguments: $group, $field
-
-Returns: $sub (\CODE)
-
-=back
-
-Returns a single accessor in a given group; called by mk_group_accessors
-for each entry in @fieldspec.
-
-=cut
-
-sub make_group_accessor {
-    my ($class, $group, $field) = @_;
-
-    my $set = "set_$group";
-    my $get = "get_$group";
-
-    # Build a closure around $field.
-    return sub {
-        my $self = shift;
-
-        if(@_) {
-            return $self->$set($field, @_);
-        }
-        else {
-            return $self->$get($field);
-        }
-    };
-}
-
-=head2 make_group_ro_accessor
-
-=over 4
-
-=item Arguments: $group, $field
-
-Returns: $sub (\CODE)
-
-=back
-
-Returns a single read-only accessor in a given group; called by
-mk_group_ro_accessors for each entry in @fieldspec.
-
-=cut
-
-sub make_group_ro_accessor {
-    my($class, $group, $field) = @_;
-
-    my $get = "get_$group";
-
-    return sub {
-        my $self = shift;
-
-        if(@_) {
-            my $caller = caller;
-            croak("'$caller' cannot alter the value of '$field' on ".
-                        "objects of class '$class'");
-        }
-        else {
-            return $self->$get($field);
-        }
-    };
-}
-
-=head2 make_group_wo_accessor
-
-=over 4
-
-=item Arguments: $group, $field
-
-Returns: $sub (\CODE)
-
-=back
-
-Returns a single write-only accessor in a given group; called by
-mk_group_wo_accessors for each entry in @fieldspec.
-
-=cut
-
-sub make_group_wo_accessor {
-    my($class, $group, $field) = @_;
-
-    my $set = "set_$group";
-
-    return sub {
-        my $self = shift;
-
-        unless (@_) {
-            my $caller = caller;
-            croak("'$caller' cannot access the value of '$field' on ".
-                        "objects of class '$class'");
-        }
-        else {
-            return $self->$set($field, @_);
-        }
-    };
-}
-
-=head2 get_simple
-
-=over 4
-
-=item Arguments: $field
-
-Returns: $value
-
-=back
-
-Simple getter for hash-based objects which returns the value for the field
-name passed as an argument.
-
-=cut
-
-sub get_simple {
-  my ($self, $get) = @_;
-  return $self->{$get};
-}
-
-=head2 set_simple
-
-=over 4
-
-=item Arguments: $field, $new_value
-
-Returns: $new_value
-
-=back
-
-Simple setter for hash-based objects which sets and then returns the value
-for the field name passed as an argument.
-
-=cut
-
-sub set_simple {
-  my ($self, $set, $val) = @_;
-  return $self->{$set} = $val;
-}
-
-=head2 get_component_class
-
-=over 4
-
-=item Arguments: $name
-
-Returns: $component_class
-
-=back
-
-Returns the class name for a component; returns an object key if called on
-an object, or attempts to return classdata referenced by _$name if called
-on a class.
-
-=cut
-
-sub get_component_class {
-  my ($self, $get) = @_;
-  if (ref $self) {
-      return $self->{$get};
-  } else {
-      $get = "_$get";
-      return $self->can($get) ? $self->$get : undef;
-  }
-}
-
-=head2 set_component_class
-
-=over 4
-
-=item Arguments: $name, $new_component_class
-
-Returns: $new_component_class
-
-=back
-
-Sets a component class name; attempts to require the class before setting
-but does not error if unable to do so. Sets an object key of the given name
-if called or an object or classdata called _$name if called on a class.
-
-=cut
-
-sub set_component_class {
-  my ($self, $set, $val) = @_;
-  eval "require $val";
-  if ($@) {
-      my $val_path = $val;
-      $val_path =~ s{::}{/}g;
-      carp $@ unless $@ =~ /^Can't locate $val_path\.pm/;
-  }
-  if (ref $self) {
-      return $self->{$set} = $val;
-  } else {
-      $set = "_$set";
-      return $self->can($set) ?
-        $self->$set($val) :
-        $self->mk_classdata($set => $val);
-  }
-}
-
-1;
-
-=head1 AUTHORS
-
-Matt S. Trout <mst@shadowcatsystems.co.uk>
-
-=head1 LICENSE
-
-You may distribute this code under the same terms as Perl itself.
-
-=cut
-
index 7c48181..504480e 100644 (file)
@@ -14,7 +14,7 @@ __PACKAGE__->load_components(qw/
   PK
   Row
   ResultSourceProxy::Table
-  AccessorGroup/);
+  /);
 
 1;
 
@@ -50,8 +50,6 @@ The core modules currently are:
 
 =item L<DBIx::Class::ResultSourceProxy::Table>
 
-=item L<DBIx::Class::AccessorGroup>
-
 =back
 
 =head1 AUTHORS
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 6a5a046..c987bb5 100644 (file)
@@ -125,7 +125,7 @@ The above belongs_to relationship could also have been specified as,
 
   My::DBIC::Schema::Book->belongs_to( author,
                                       'My::DBIC::Schema::Author',
-                                      { 'self.author' => 'foreign.author' } );
+                                      { 'foreign.author' => 'self.author' } );
 
 Creates a relationship where the calling class stores the foreign class's
 primary key in one (or more) of its columns. This relationship defaults to
@@ -308,9 +308,11 @@ And, for the reverse relationship, from Role to Actor:
 
   My::DBIC::Schema::Role->many_to_many( actors => 'actor_roles', 'actor' );
 
-Creates accessors bridging two relationships; not strictly a relationship in
-its own right, although the accessor will return a resultset or collection of
-objects just as a has_many would.
+Many_to_many is not strictly a relationship in its own right. Instead, it is
+a bridge between two resultsets which provide the same kind of convenience
+accessors as true relationships provide. Although the accessor will return a 
+resultset or collection of objects just like has_many does, you cannot call 
+C<$related_resultset> and similar methods which operate on true relationships.
 
 In the above example, ActorRoles is the link table class, and Role is the
 foreign class. The C<$link_rel_name> parameter is the name of the accessor for
index 7e74edf..b6fbb05 100644 (file)
@@ -12,7 +12,6 @@ use Storable;
 use DBIx::Class::ResultSetColumn;
 use base qw/DBIx::Class/;
 
-__PACKAGE__->load_components(qw/AccessorGroup/);
 __PACKAGE__->mk_group_accessors('simple' => qw/result_source result_class/);
 
 =head1 NAME
@@ -536,7 +535,7 @@ sub single {
     $attrs->{where}, $attrs
   );
 
-  return (@data ? $self->_construct_object(@data) : ());
+  return (@data ? ($self->_construct_object(@data))[0] : ());
 }
 
 # _is_unique_query
@@ -721,22 +720,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..8cc5b6c 100644 (file)
@@ -8,14 +8,13 @@ use Carp::Clan qw/^DBIx::Class/;
 use Storable;
 
 use base qw/DBIx::Class/;
-__PACKAGE__->load_components(qw/AccessorGroup/);
 
 __PACKAGE__->mk_group_accessors('simple' => qw/_ordered_columns
   _columns _primaries _unique_constraints name resultset_attributes
   schema from _relationships column_info_from_storage source_name
   source_info/);
 
-__PACKAGE__->mk_group_accessors('component_class' => qw/resultset_class
+__PACKAGE__->mk_group_accessors('inherited' => qw/resultset_class
   result_class/);
 
 =head1 NAME
@@ -108,29 +107,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 +140,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
@@ -201,8 +210,8 @@ sub column_info {
        and $self->schema and $self->storage )
   {
     $self->{_columns_info_loaded}++;
-    my $info;
-    my $lc_info;
+    my $info = {};
+    my $lc_info = {};
     # eval for the case of storage without table
     eval { $info = $self->storage->columns_info_for( $self->from ) };
     unless ($@) {
@@ -210,7 +219,10 @@ sub column_info {
         $lc_info->{lc $realcol} = $info->{$realcol};
       }
       foreach my $col ( keys %{$self->_columns} ) {
-        $self->_columns->{$col} = { %{ $self->_columns->{$col}}, %{$info->{$col} || $lc_info->{lc $col}} };
+        $self->_columns->{$col} = {
+          %{ $self->_columns->{$col} },
+          %{ $info->{$col} || $lc_info->{lc $col} || {} }
+        };
       }
     }
   }
@@ -931,12 +943,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
index f70f2bc..0816dd7 100644 (file)
@@ -4,10 +4,10 @@ use strict;
 use warnings;
 
 use base qw/DBIx::Class::ResultSourceProxy/;
-__PACKAGE__->load_components(qw/AccessorGroup/);
 
-__PACKAGE__->mk_group_accessors('component_class' => 'table_class');
-__PACKAGE__->table_class('DBIx::Class::ResultSource::Table');
+use DBIx::Class::ResultSource::Table;
+
+__PACKAGE__->mk_classdata(table_class => 'DBIx::Class::ResultSource::Table');
 
 __PACKAGE__->mk_classdata('table_alias'); # FIXME: Doesn't actually do
                                           # anything yet!
index 57f883f..7d9298d 100644 (file)
@@ -6,8 +6,6 @@ use warnings;
 use base qw/DBIx::Class/;
 use Carp::Clan qw/^DBIx::Class/;
 
-__PACKAGE__->load_components(qw/AccessorGroup/);
-
 __PACKAGE__->mk_group_accessors('simple' => 'result_source');
 
 =head1 NAME
index f98001b..9a58b94 100644 (file)
@@ -8,7 +8,6 @@ use base qw/DBIx::Class/;
 use Scalar::Util qw/weaken/;
 use Carp::Clan qw/^DBIx::Class/;
 
-__PACKAGE__->load_components(qw/AccessorGroup/);
 __PACKAGE__->mk_group_accessors('simple' => qw/debug debugobj schema/);
 
 package # Hide from PAUSE
index 09f79da..5d0ba47 100644 (file)
@@ -2,7 +2,8 @@ package DBIx::Class::Storage::Statistics;
 use strict;
 use warnings;
 
-use base qw/DBIx::Class::AccessorGroup Class::Data::Accessor/;
+use base qw/Class::Accessor::Grouped/;
+
 __PACKAGE__->mk_group_accessors(simple => qw/callback debugfh/);
 
 =head1 NAME
index 7307c6f..b62d622 100644 (file)
@@ -23,7 +23,7 @@ plan tests => 5;
 # tests run on windows as well
 
 my $employees = $schema->resultset('Employee');
-my $cmd = qq|perl script/dbicadmin --schema=DBICTest::Schema --class=Employee --tlibs --connect="['dbi:SQLite:dbname=t/var/DBIxClass.db','','']" --force --tlibs|;
+my $cmd = qq|$^X script/dbicadmin --schema=DBICTest::Schema --class=Employee --tlibs --connect="['dbi:SQLite:dbname=t/var/DBIxClass.db','','']" --force --tlibs|;
 
 `$cmd --op=insert --set="{name:'Matt'}"`;
 ok( ($employees->count()==1), 'insert count' );
diff --git a/t/95sql_maker_quote.t b/t/95sql_maker_quote.t
new file mode 100644 (file)
index 0000000..dc33199
--- /dev/null
@@ -0,0 +1,196 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+
+BEGIN {
+    eval "use DBD::SQLite";
+    plan $@
+        ? ( skip_all => 'needs DBD::SQLite for testing' )
+        : ( tests => 8 );
+}
+
+use lib qw(t/lib);
+
+use_ok('DBICTest');
+
+DBICTest->init_schema();
+
+my $sql_maker = DBICTest->schema->storage->sql_maker;
+
+$sql_maker->quote_char('`');
+$sql_maker->name_sep('.');
+
+my ($sql,) = $sql_maker->select(
+          [
+            {
+              'me' => 'cd'
+            },
+            [
+              {
+                'artist' => 'artist',
+                '-join_type' => ''
+              },
+              {
+                'artist.artistid' => 'me.artist'
+              }
+            ]
+          ],
+          [
+            {
+              'count' => '*'
+            }
+          ],
+          {
+            'artist.name' => 'Caterwauler McCrae',
+            'me.year' => 2001
+          },
+          [],
+          undef,
+          undef
+);
+
+is($sql, 
+   q/SELECT COUNT( * ) FROM `cd` `me`  JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )/, 
+   'got correct SQL for count query with quoting');
+
+($sql,) = $sql_maker->select(
+          [
+            {
+              'me' => 'cd'
+            }
+          ],
+          [
+            'me.cdid',
+            'me.artist',
+            'me.title',
+            'me.year'
+          ],
+          undef,
+          [
+            'year DESC'
+          ],
+          undef,
+          undef
+);
+
+TODO: {
+    local $TODO = "order_by with quoting needs fixing (ash/castaway)";
+
+    is($sql, 
+       q/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY `year` DESC/, 
+       'quoted ORDER BY with DESC okay');
+}
+
+TODO: {
+    local $TODO = "select attr with star needs fixing (mst/nate)";
+
+    ($sql,) = $sql_maker->select(
+          [
+            {
+              'me' => 'cd'
+            }
+          ],
+          [
+            'me.*'
+          ],
+          undef,
+          [],
+          undef,
+          undef    
+    );
+
+    is($sql, q/SELECT `me`.* FROM `cd` `me`/, 'select attr with me.* is right');
+}
+
+($sql,) = $sql_maker->select(
+          [
+            {
+              'me' => 'cd'
+            }
+          ],
+          [
+            'me.cdid',
+            'me.artist',
+            'me.title',
+            'me.year'
+          ],
+          undef,
+          [
+            \'year DESC'
+          ],
+          undef,
+          undef
+);
+
+is($sql, 
+   q/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY year DESC/,
+   'did not quote ORDER BY with scalarref');
+
+my %data = ( 
+    name => 'Bill',
+    order => 12
+);
+
+my @binds;
+
+($sql,@binds) = $sql_maker->update(
+          'group',
+          {
+            'order' => '12',
+            'name' => 'Bill'
+          }
+);
+
+is($sql,
+   q/UPDATE `group` SET `name` = ?, `order` = ?/,
+   'quoted table names for UPDATE');
+
+$sql_maker->quote_char([qw/[ ]/]);
+
+($sql,) = $sql_maker->select(
+          [
+            {
+              'me' => 'cd'
+            },
+            [
+              {
+                'artist' => 'artist',
+                '-join_type' => ''
+              },
+              {
+                'artist.artistid' => 'me.artist'
+              }
+            ]
+          ],
+          [
+            {
+              'count' => '*'
+            }
+          ],
+          {
+            'artist.name' => 'Caterwauler McCrae',
+            'me.year' => 2001
+          },
+          [],
+          undef,
+          undef
+);
+
+is($sql,
+   q/SELECT COUNT( * ) FROM [cd] [me]  JOIN [artist] [artist] ON ( [artist].[artistid] = [me].[artist] ) WHERE ( [artist].[name] = ? AND [me].[year] = ? )/,
+   'got correct SQL for count query with bracket quoting');
+
+
+($sql,@binds) = $sql_maker->update(
+          'group',
+          {
+            'order' => '12',
+            'name' => 'Bill'
+          }
+);
+
+is($sql,
+   q/UPDATE [group] SET [name] = ?, [order] = ?/,
+   'bracket quoted table names for UPDATE');