Merge 'trunk' into 'table_name_ref'
Rafael Kitover [Thu, 6 Aug 2009 13:48:54 +0000 (13:48 +0000)]
r9068@hlagh (orig r7198):  caelum | 2009-08-04 16:18:27 -0400
update Changes
r9075@hlagh (orig r7205):  ribasushi | 2009-08-05 02:34:25 -0400
Bump dependencies:
Test::More for the new no_plan/done_testing goodies
File::Temp as per RT#48431
r9077@hlagh (orig r7207):  ribasushi | 2009-08-05 02:36:32 -0400
 r7156@Thesaurus (orig r7153):  robkinyon | 2009-07-30 20:06:04 +0200
 Create prefetch_redux branch
 r7164@Thesaurus (orig r7161):  robkinyon | 2009-07-31 22:41:01 +0200
 Added MooseX::Traits to Makefile.PL
 r7172@Thesaurus (orig r7169):  robkinyon | 2009-08-03 05:49:59 +0200
 Added two tests and marked one todo_skip
 r7187@Thesaurus (orig r7184):  ribasushi | 2009-08-03 17:24:41 +0200
 Use goto to preserve correct error-at-line reporting
 r7189@Thesaurus (orig r7186):  ribasushi | 2009-08-04 12:34:58 +0200
 Add an extra test specifically for distinct/prefetch
 Remove duplicate test in count/prefetch

 Switch to as_query instead of debug overloading
 r7190@Thesaurus (orig r7187):  ribasushi | 2009-08-04 12:35:57 +0200
 Fix how a distinct-induced group_by is calculated, taking in consideration the new prefetch mechanism
 r7197@Thesaurus (orig r7194):  ribasushi | 2009-08-04 17:31:33 +0200
 Traits not needed by anything currently in dbic
 r7198@Thesaurus (orig r7195):  ribasushi | 2009-08-04 17:41:14 +0200
 Move around tests a bit
 r7199@Thesaurus (orig r7196):  mo | 2009-08-04 21:10:57 +0200
 prefetch-grouped fails, again
 r7204@Thesaurus (orig r7201):  ribasushi | 2009-08-04 22:50:51 +0200
 Split the search_related prefetch tests into a standalone testfile
 r7205@Thesaurus (orig r7202):  ribasushi | 2009-08-04 23:05:03 +0200
 Move norbi's test to prefetch_redux - it's the same idea
 r7209@Thesaurus (orig r7206):  ribasushi | 2009-08-05 08:35:48 +0200
 Tadaaaa (even more prefetch insanity)

r9079@hlagh (orig r7209):  ribasushi | 2009-08-05 02:38:41 -0400
 r7107@Thesaurus (orig r7104):  caelum | 2009-07-24 06:51:57 +0200
 new branch to move common mssql functionality into the base class, and other tweaks
 r7109@Thesaurus (orig r7106):  caelum | 2009-07-24 07:28:11 +0200
 moved code to ::DBI::MSSQL and added DT inflation test
 r7112@Thesaurus (orig r7109):  caelum | 2009-07-24 08:46:16 +0200
 merge in some more MSSQL code, including odbc dynamic cursor support
 r7113@Thesaurus (orig r7110):  caelum | 2009-07-24 08:49:54 +0200
 fix a warning in SQLAHacks
 r7114@Thesaurus (orig r7111):  caelum | 2009-07-24 09:22:33 +0200
 add placeholder support detection for mssql through dbd::sybase
 r7118@Thesaurus (orig r7115):  caelum | 2009-07-24 16:39:06 +0200
 minor doc clarification
 r7122@Thesaurus (orig r7119):  caelum | 2009-07-25 16:10:30 +0200
 move placeholder support detection into ::Sybase::Base
 r7123@Thesaurus (orig r7120):  caelum | 2009-07-25 16:12:01 +0200
 add a comment
 r7127@Thesaurus (orig r7124):  caelum | 2009-07-26 18:04:29 +0200
 SAVEPOINT methods for MSSQL
 r7140@Thesaurus (orig r7137):  caelum | 2009-07-30 10:12:45 +0200
 better tests for "smalldatetime" support in MSSQL
 r7142@Thesaurus (orig r7139):  caelum | 2009-07-30 13:29:19 +0200
 MSSQL GUID support
 r7147@Thesaurus (orig r7144):  caelum | 2009-07-30 15:38:33 +0200
 update sqlite test schema
 r7150@Thesaurus (orig r7147):  caelum | 2009-07-30 16:26:47 +0200
 make sure the new mssql insert method works on an un-reblessed storage
 r7151@Thesaurus (orig r7148):  caelum | 2009-07-30 16:55:35 +0200
 better rebless check for insert
 r7154@Thesaurus (orig r7151):  caelum | 2009-07-30 18:57:22 +0200
 add missing file
 r7155@Thesaurus (orig r7152):  caelum | 2009-07-30 19:00:40 +0200
 fix syntax error
 r7163@Thesaurus (orig r7160):  caelum | 2009-07-31 15:52:41 +0200
 fix a bug in _determine_driver
 r7166@Thesaurus (orig r7163):  caelum | 2009-08-01 18:10:23 +0200
 default collist for storage _resolve_column_info
 r7182@Thesaurus (orig r7179):  caelum | 2009-08-03 13:42:31 +0200
 check that dynamic cursors are functional if enabled
 r7184@Thesaurus (orig r7181):  ribasushi | 2009-08-03 14:23:37 +0200
 Adjust expected sql to match the new 'Track' table definition
 r7186@Thesaurus (orig r7183):  ribasushi | 2009-08-03 15:16:10 +0200
 Simplify code and add some comments
 r7200@Thesaurus (orig r7197):  caelum | 2009-08-04 21:31:16 +0200
 update oracle tests for new "track" table
 r7203@Thesaurus (orig r7200):  caelum | 2009-08-04 22:39:57 +0200
 update Changes

r9081@hlagh (orig r7211):  ribasushi | 2009-08-05 02:40:39 -0400
 r7213@Thesaurus (orig r7210):  ribasushi | 2009-08-05 08:40:20 +0200
 Really sanify _resolve_column_info

r9083@hlagh (orig r7213):  ribasushi | 2009-08-05 04:19:37 -0400
Reminder about discard_changes and friends
r9084@hlagh (orig r7214):  ribasushi | 2009-08-05 04:26:20 -0400
Reformat and fill-in changes
r9085@hlagh (orig r7215):  caelum | 2009-08-05 04:37:12 -0400
rename connect_call_use_mars to connect_call_use_MARS
r9086@hlagh (orig r7216):  ribasushi | 2009-08-05 04:38:14 -0400
Silence a TODO test
r9087@hlagh (orig r7217):  caelum | 2009-08-05 04:46:11 -0400
minor Changes update
r9097@hlagh (orig r7227):  castaway | 2009-08-05 08:57:52 -0400
Minty's conversion of cookbook "arbitrary sql" to use ResultSource::View, plus some examples in ::View itself.
Some style tweaks of mine

r9098@hlagh (orig r7228):  ribasushi | 2009-08-05 09:41:28 -0400
Dynamically load necessary table classes
r9103@hlagh (orig r7233):  caelum | 2009-08-05 13:49:51 -0400
fix rounding issues in mssql money tests
r9104@hlagh (orig r7234):  caelum | 2009-08-05 14:09:03 -0400
better money value comparison in tests
r9106@hlagh (orig r7236):  frew | 2009-08-05 14:53:32 -0400
whitespace jfklds;ajfklds;a
r9107@hlagh (orig r7237):  frew | 2009-08-05 14:54:41 -0400
Fix testing bug.  Windows only.

1  2 
lib/DBIx/Class/ResultSource.pm
lib/DBIx/Class/ResultSourceProxy/Table.pm
lib/DBIx/Class/SQLAHacks.pm

@@@ -40,8 -40,6 +40,6 @@@ DBIx::Class::ResultSource - Result sour
    # Create a query (view) based result source, in a result class
    package MyDB::Schema::Result::Year2000CDs;
  
-   use DBIx::Class::ResultSource::View;
    __PACKAGE__->load_components('Core');
    __PACKAGE__->table_class('DBIx::Class::ResultSource::View');
  
@@@ -245,9 -243,15 +243,15 @@@ automatically
  
  =item auto_nextval
  
- Set this to a true value for a column whose value is retrieved
- automatically from an oracle sequence. If you do not use an Oracle
- trigger to get the nextval, you have to set sequence as well.
+ Set this to a true value for a column whose value is retrieved automatically
+ from a sequence or function (if supported by your Storage driver.) For a
+ sequence, if you do not use a trigger to get the nextval, you have to set the
+ L</sequence> value as well.
+ Also set this for MSSQL columns with the 'uniqueidentifier'
+ L<DBIx::Class::ResultSource/data_type> whose values you want to automatically
+ generate using C<NEWID()>, unless they are a primary key in which case this will
+ be done anyway.
  
  =item extra
  
@@@ -580,10 -584,7 +584,10 @@@ optional constraint name
  sub name_unique_constraint {
    my ($self, $cols) = @_;
  
 -  return join '_', $self->name, @$cols;
 +  my $name = $self->name;
 +  $name = $$name if ref $name;
 +
 +  return join '_', $name, @$cols;
  }
  
  =head2 unique_constraints
@@@ -5,9 -5,6 +5,9 @@@ use warnings
  
  use base qw/DBIx::Class::ResultSourceProxy/;
  
 +use DBIx::Class::ResultSource::Table;
 +use Scalar::Util ();
 +
  __PACKAGE__->mk_classdata(table_class => 'DBIx::Class::ResultSource::Table');
  
  __PACKAGE__->mk_classdata('table_alias'); # FIXME: Doesn't actually do
@@@ -23,8 -20,11 +23,11 @@@ sub _init_result_source_instance 
      my $class_has_table_instance = ($table and $table->result_class eq $class);
      return $table if $class_has_table_instance;
  
+     my $table_class = $class->table_class;
+     $class->ensure_class_loaded($table_class);
      if( $table ) {
-         $table = $class->table_class->new({
+         $table = $table_class->new({
              %$table,
              result_class => $class,
              source_name => undef,
@@@ -32,7 -32,7 +35,7 @@@
          });
      }
      else {
-         $table = $class->table_class->new({
+         $table = $table_class->new({
              name            => undef,
              result_class    => $class,
              source_name     => undef,
@@@ -76,9 -76,12 +79,13 @@@ Gets or sets the table name
  sub table {
    my ($class, $table) = @_;
    return $class->result_source_instance->name unless $table;
 -  unless (ref $table) {
 +
 +  unless (Scalar::Util::blessed($table) && $table->isa($class->table_class)) {
-     $table = $class->table_class->new({
+     my $table_class = $class->table_class;
+     $class->ensure_class_loaded($table_class);
+     $table = $table_class->new({
          $class->can('result_source_instance') ?
            %{$class->result_source_instance||{}} : (),
          name => $table,
@@@ -170,7 -170,8 +170,8 @@@ sub _Top 
        $quoted_alias = $self->_quote ('column_' . (@inner_select + 1) );
      }
      # column name seen more than once - alias it
-     elsif ($orig_colname && ($seen_names{$orig_colname} > 1) ) {
+     elsif ($orig_colname &&
+           ($seen_names{$orig_colname} && $seen_names{$orig_colname} > 1) ) {
        $quoted_alias = $self->_quote ("${table}__${orig_colname}");
      }
  
@@@ -328,10 -329,12 +329,10 @@@ sub select 
  
    $self->{"${_}_bind"} = [] for (qw/having from order/);
  
 -  if (ref $table eq 'SCALAR') {
 -    $table = $$table;
 -  }
 -  elsif (not ref $table) {
 +  if (not ref($table) or ref($table) eq 'SCALAR') {
      $table = $self->_quote($table);
    }
 +
    local $self->{rownum_hack_count} = 1
      if (defined $rest[0] && $self->{limit_dialect} eq 'RowNum');
    @rest = (-1) unless defined $rest[0];
  sub insert {
    my $self = shift;
    my $table = shift;
 -  $table = $self->_quote($table) unless ref($table);
 +  $table = $self->_quote($table);
  
    # SQLA will emit INSERT INTO $table ( ) VALUES ( )
    # which is sadly understood only by MySQL. Change default behavior here,
  sub update {
    my $self = shift;
    my $table = shift;
 -  $table = $self->_quote($table) unless ref($table);
 +  $table = $self->_quote($table);
    $self->SUPER::update($table, @_);
  }
  
  sub delete {
    my $self = shift;
    my $table = shift;
 -  $table = $self->_quote($table) unless ref($table);
 +  $table = $self->_quote($table);
    $self->SUPER::delete($table, @_);
  }
  
@@@ -581,7 -584,6 +582,7 @@@ sub _join_condition 
  sub _quote {
    my ($self, $label) = @_;
    return '' unless defined $label;
 +  return $$label if ref($label) eq 'SCALAR';
    return "*" if $label eq '*';
    return $label unless $self->{quote_char};
    if(ref $self->{quote_char} eq "ARRAY"){