Merge 'trunk' into 'mssql_limit_regression'
Peter Rabbitson [Fri, 8 Jan 2010 18:19:41 +0000 (18:19 +0000)]
r8076@Thesaurus (orig r8064):  ribasushi | 2009-12-12 12:31:12 +0100
Even clearer unloaded FK exception
r8078@Thesaurus (orig r8066):  ribasushi | 2009-12-12 14:27:18 +0100
As clear as it gets
r8141@Thesaurus (orig r8129):  ovid | 2009-12-16 17:40:50 +0100
Have has_one/might_have warn if set on nullable columns.

r8143@Thesaurus (orig r8131):  caelum | 2009-12-17 13:30:10 +0100
somewhat better fix for ADO
r8144@Thesaurus (orig r8132):  caelum | 2009-12-17 13:34:20 +0100
minor changes
r8146@Thesaurus (orig r8134):  caelum | 2009-12-17 17:44:34 +0100
cleanup source_bind_attributes for ADO
r8147@Thesaurus (orig r8135):  caelum | 2009-12-17 18:09:55 +0100
more types for ADO fix, and documentation
r8148@Thesaurus (orig r8136):  abraxxa | 2009-12-17 19:54:55 +0100
Cookbook POD fix for add_drop_table instead of add_drop_tables

r8158@Thesaurus (orig r8146):  ribasushi | 2009-12-18 14:55:53 +0100
 r8150@Thesaurus (orig r8138):  abraxxa | 2009-12-17 23:22:07 +0100
 Views without a view_definition won't be added to the SQL::Translator::Schema by the parser + tests

 r8151@Thesaurus (orig r8139):  abraxxa | 2009-12-17 23:23:33 +0100
 test cleanups

 r8153@Thesaurus (orig r8141):  abraxxa | 2009-12-18 14:34:14 +0100
 throw_exception if view_definition is missing instead of silent skipping + test changes

 r8154@Thesaurus (orig r8142):  abraxxa | 2009-12-18 14:40:32 +0100
 use Test::Exception

 r8155@Thesaurus (orig r8143):  abraxxa | 2009-12-18 14:42:00 +0100
 fixed Changes

 r8156@Thesaurus (orig r8144):  abraxxa | 2009-12-18 14:44:52 +0100
 test cleanups

 r8157@Thesaurus (orig r8145):  ribasushi | 2009-12-18 14:46:26 +0100
 Another bitr

r8160@Thesaurus (orig r8148):  ribasushi | 2009-12-18 15:04:34 +0100
Fix no_index entries
r8162@Thesaurus (orig r8150):  abraxxa | 2009-12-18 15:59:58 +0100
Schema POD inprovement for dclone

r8163@Thesaurus (orig r8151):  abraxxa | 2009-12-18 16:07:27 +0100
link to DBIx::Class::Row

r8164@Thesaurus (orig r8152):  abraxxa | 2009-12-18 16:08:56 +0100
fixed typo in Changes

r8165@Thesaurus (orig r8153):  abraxxa | 2009-12-18 16:14:47 +0100
dclone pod take #2

r8169@Thesaurus (orig r8157):  ribasushi | 2009-12-19 18:47:42 +0100
detabify
r8170@Thesaurus (orig r8158):  ribasushi | 2009-12-19 19:41:42 +0100
Fix RT52812
r8171@Thesaurus (orig r8159):  caelum | 2009-12-23 07:16:29 +0100
minor POD fixes
r8175@Thesaurus (orig r8163):  ribasushi | 2009-12-24 09:59:52 +0100
Fix deployment_statements context sensitivity regression
r8176@Thesaurus (orig r8164):  ribasushi | 2009-12-24 10:13:37 +0100
Don't call the PK setter if no PK
r8204@Thesaurus (orig r8192):  caelum | 2009-12-30 22:58:47 +0100
bump CAG dep
r8231@Thesaurus (orig r8219):  matthewt | 2010-01-02 01:41:12 +0100
fix typo in variable name
r8238@Thesaurus (orig r8226):  rafl | 2010-01-02 18:46:40 +0100
Merge branch 'native_traits'

* native_traits:
  Port replicated storage from MXAH to native traits.
  Create branch native_traits
r8244@Thesaurus (orig r8232):  caelum | 2010-01-04 00:30:51 +0100
fix _rebless into sybase/mssql/nobindvars
r8247@Thesaurus (orig r8235):  caelum | 2010-01-05 13:54:56 +0100
 r22328@hlagh (orig r8201):  caelum | 2009-12-31 12:29:51 -0500
 new branch to fix table aliases in queries over the 30char limit
 r22329@hlagh (orig r8202):  caelum | 2009-12-31 12:55:50 -0500
 failing test
 r22330@hlagh (orig r8203):  caelum | 2009-12-31 13:00:35 -0500
 switch oracle tests to done_testing()
 r22331@hlagh (orig r8204):  caelum | 2009-12-31 15:02:50 -0500
 got something working
 r22332@hlagh (orig r8205):  caelum | 2009-12-31 15:08:30 -0500
 POD touchups
 r22343@hlagh (orig r8216):  caelum | 2010-01-01 07:42:03 -0500
 fix uninitialized warning and a bug in ResultSet
 r22419@hlagh (orig r8234):  caelum | 2010-01-05 07:53:18 -0500
 append half of a base64 MD5 to shortened table aliases for Oracle

r8249@Thesaurus (orig r8237):  caelum | 2010-01-05 15:27:40 +0100
minor change: use more of the hash if possible for oracle table alias shortening
r8251@Thesaurus (orig r8239):  caelum | 2010-01-06 02:20:17 +0100
bump perl_version to 5.8.1
r8252@Thesaurus (orig r8240):  caelum | 2010-01-06 02:21:41 +0100
remove alignment mark on base64 md5
r8260@Thesaurus (orig r8248):  ribasushi | 2010-01-07 11:21:55 +0100
5.8.1 is minimum required perl
r8261@Thesaurus (orig r8249):  ribasushi | 2010-01-07 11:22:42 +0100
Minor optimization
r8262@Thesaurus (orig r8250):  ribasushi | 2010-01-07 11:23:35 +0100
Wrong title
r8265@Thesaurus (orig r8253):  ribasushi | 2010-01-08 17:48:50 +0100
Resolve problem reported by http://lists.scsys.co.uk/pipermail/dbix-class/2009-December/008699.html
r8266@Thesaurus (orig r8254):  ribasushi | 2010-01-08 17:52:01 +0100
Put utf8columns in line with the store_column fix
r8267@Thesaurus (orig r8255):  ribasushi | 2010-01-08 19:03:26 +0100
Tests while hunting for something else
r8268@Thesaurus (orig r8256):  ribasushi | 2010-01-08 19:14:42 +0100
Make test look even more like http://lists.scsys.co.uk/pipermail/dbix-class/2009-November/008599.html

1  2 
Changes
lib/DBIx/Class/ResultSet.pm
lib/DBIx/Class/Storage/DBI.pm

diff --combined Changes
+++ b/Changes
@@@ -1,9 -1,15 +1,17 @@@
  Revision history for DBIx::Class
  
+         - Perl 5.8.1 is now the minimum supported version
+         - might_have/has_one now warn if applied calling class's column
+           has is_nullable set to true.
+         - Fixed regression in deploy() with a {sources} table limit applied
+           (RT#52812)
+         - Cookbook POD fix for add_drop_table instead of add_drop_tables
+         - Views without a view_definition will throw an exception when
+           parsed by SQL::Translator::Parser::DBIx::Class
+         - Schema POD improvement for dclone
+         - Fix regression in context sensitiveness of deployment_statements
 +        - Fix regression resulting in overcomplicated query on
 +          search_related from prefetching resultsets
-         - Better isolation of RNO-limited queries from the rest
-           of a prefetching resultset
  
  0.08115 2009-12-10 09:02:00 (CST)
          - Real limit/offset support for MSSQL server (via Row_Number)
@@@ -1431,7 -1431,7 +1431,7 @@@ sub _rs_update_delete 
    my $cond = $rsrc->schema->storage->_strip_cond_qualifiers ($self->{cond});
  
    my $needs_group_by_subq = $self->_has_resolved_attr (qw/collapse group_by -join/);
-   my $needs_subq = (not defined $cond) || $self->_has_resolved_attr(qw/row offset/);
+   my $needs_subq = $needs_group_by_subq || (not defined $cond) || $self->_has_resolved_attr(qw/row offset/);
  
    if ($needs_group_by_subq or $needs_subq) {
  
@@@ -2522,7 -2522,9 +2522,9 @@@ sub related_resultset 
      my $attrs = $self->_chain_relationship($rel);
  
      my $join_count = $attrs->{seen_join}{$rel};
-     my $alias = ($join_count > 1 ? join('_', $rel, $join_count) : $rel);
+     my $alias = $self->result_source->storage
+         ->relname_to_table_alias($rel, $join_count);
  
      #XXX - temp fix for result_class bug. There likely is a more elegant fix -groditi
      delete @{$attrs}{qw(result_class alias)};
@@@ -2638,19 -2640,10 +2640,19 @@@ sub _chain_relationship 
        ||
      $self->_has_resolved_attr (@force_subq_attrs)
    ) {
 +    # Nuke the prefetch (if any) before the new $rs attrs
 +    # are resolved (prefetch is useless - we are wrapping
 +    # a subquery anyway).
 +    my $rs_copy = $self->search;
 +    $rs_copy->{attrs}{join} = $self->_merge_attr (
 +      $rs_copy->{attrs}{join},
 +      delete $rs_copy->{attrs}{prefetch},
 +    );
 +
      $from = [{
        -source_handle => $source->handle,
        -alias => $attrs->{alias},
 -      $attrs->{alias} => $self->as_query,
 +      $attrs->{alias} => $rs_copy->as_query,
      }];
      delete @{$attrs}{@force_subq_attrs, 'where'};
      $seen->{-relation_chain_depth} = 0;
@@@ -1290,12 -1290,6 +1290,6 @@@ sub _query_end 
      }
  }
  
- sub _sth_bind_param {
-   my ($self, $sth, $placeholder_index, $data, $attributes) = @_;
-   $sth->bind_param($placeholder_index, $data, $attributes);
- }
  sub _dbh_execute {
    my ($self, $dbh, $op, $extra_bind, $ident, $bind_attributes, @args) = @_;
  
        my $ref = ref $data;
        $data = $ref && $ref ne 'ARRAY' ? ''.$data : $data; # stringify args (except arrayrefs)
  
-       $self->_sth_bind_param($sth, $placeholder_index, $data, $attributes);
+       $sth->bind_param($placeholder_index, $data, $attributes);
        $placeholder_index++;
      }
    }
@@@ -1774,24 -1768,11 +1768,24 @@@ sub _select_args 
  
    my @limit;
  
 -  # see if we need to tear the prefetch apart (either limited has_many or grouped prefetch)
 -  # otherwise delegate the limiting to the storage, unless software limit was requested
 +  # see if we need to tear the prefetch apart otherwise delegate the limiting to the
 +  # storage, unless software limit was requested
    if (
 +    #limited has_many
      ( $attrs->{rows} && keys %{$attrs->{collapse}} )
         ||
 +    # limited prefetch with RNO subqueries
 +    (
 +      $attrs->{rows}
 +        &&
 +      $sql_maker->limit_dialect eq 'RowNumberOver'
 +        &&
 +      $attrs->{_prefetch_select}
 +        &&
 +      @{$attrs->{_prefetch_select}}
 +    )
 +      ||
 +    # grouped prefetch
      ( $attrs->{group_by}
          &&
        @{$attrs->{group_by}}
        @{$attrs->{_prefetch_select}}
      )
    ) {
 -
      ($ident, $select, $where, $attrs)
        = $self->_adjust_select_args_for_complex_prefetch ($ident, $select, $where, $attrs);
    }
@@@ -2391,10 -2373,19 +2385,19 @@@ sub deployment_statements 
      data => $schema,
    );
  
-   my $ret = $tr->translate
-     or $self->throw_exception( 'Unable to produce deployment statements: ' . $tr->error);
+   my @ret;
+   my $wa = wantarray;
+   if ($wa) {
+     @ret = $tr->translate;
+   }
+   else {
+     $ret[0] = $tr->translate;
+   }
  
-   return $ret;
+   $self->throw_exception( 'Unable to produce deployment statements: ' . $tr->error)
+     unless (@ret && defined $ret[0]);
+   return $wa ? @ret : $ret[0];
  }
  
  sub deploy {
@@@ -2519,6 -2510,34 +2522,34 @@@ sub lag_behind_master 
    sub _sqlt_minimum_version { $minimum_sqlt_version };
  }
  
+ =head2 relname_to_table_alias
+ =over 4
+ =item Arguments: $relname, $join_count
+ =back
+ L<DBIx::Class> uses L<DBIx::Class::Relationship> names as table aliases in
+ queries.
+ This hook is to allow specific L<DBIx::Class::Storage> drivers to change the
+ way these aliases are named.
+ The default behavior is C<"$relname_$join_count" if $join_count > 1>, otherwise
+ C<"$relname">.
+ =cut
+ sub relname_to_table_alias {
+   my ($self, $relname, $join_count) = @_;
+   my $alias = ($join_count && $join_count > 1 ?
+     join('_', $relname, $join_count) : $relname);
+   return $alias;
+ }
  sub DESTROY {
    my $self = shift;