[Bast-commits] r3992 - in DBIx-Class/0.08/branches/versioned_enhancements: . lib/DBIx lib/DBIx/Class lib/DBIx/Class/Manual lib/DBIx/Class/ResultClass lib/DBIx/Class/Storage/DBI/ODBC script t

ash at dev.catalyst.perl.org ash at dev.catalyst.perl.org
Wed Jan 30 16:27:24 GMT 2008


Author: ash
Date: 2008-01-30 16:27:24 +0000 (Wed, 30 Jan 2008)
New Revision: 3992

Modified:
   DBIx-Class/0.08/branches/versioned_enhancements/
   DBIx-Class/0.08/branches/versioned_enhancements/Changes
   DBIx-Class/0.08/branches/versioned_enhancements/Makefile.PL
   DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class.pm
   DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class/Manual/Joining.pod
   DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class/ResultClass/HashRefInflator.pm
   DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class/ResultSet.pm
   DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class/Row.pm
   DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm
   DBIx-Class/0.08/branches/versioned_enhancements/script/dbicadmin
   DBIx-Class/0.08/branches/versioned_enhancements/t/76joins.t
   DBIx-Class/0.08/branches/versioned_enhancements/t/89dbicadmin.t
Log:
 r13312 at proteus (orig r3942):  schwern | 2008-01-16 10:25:36 +0000
 Declare dep on JSON::Any rather than JSON.
 
 No reason JSON::Any should prefer JSON.pm over it's default ordering.
 r13313 at proteus (orig r3943):  schwern | 2008-01-16 10:26:26 +0000
 And fix the check in the dbicadmin test to look for JSON::Any.
 r13867 at proteus (orig r3954):  matthewt | 2008-01-18 13:03:08 +0000
 added strict and warnings to HashRefInflator, fixed inflation for empty has_many rels
 r13868 at proteus (orig r3955):  matthewt | 2008-01-20 12:28:55 +0000
 made search_rs smarter about when to preserve the cache to fix mm prefetch usage
 r13878 at proteus (orig r3965):  semifor | 2008-01-22 15:13:11 +0000
 Added build_datetime_parser method for MSSQL over ODBC.
 r13883 at proteus (orig r3970):  castaway | 2008-01-24 13:19:52 +0000
 Oops, fix joining manual to be correct
 
 r13884 at proteus (orig r3971):  castaway | 2008-01-24 23:22:49 +0000
 Version 0.08009
 
 r13885 at proteus (orig r3972):  castaway | 2008-01-24 23:36:59 +0000
 0.08009 released
 
 r13888 at proteus (orig r3975):  tomboh | 2008-01-25 17:20:38 +0000
 Fix a typo and a couple of links.
 



Property changes on: DBIx-Class/0.08/branches/versioned_enhancements
___________________________________________________________________
Name: svk:merge
   - 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/on_disconnect_do:3694
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/trunk:3925
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:2222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-joins:173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-resultset:570
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/datetime:1716
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_compat:1855
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_unique_query_fixes:2142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/inflate:1988
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/re_refactor_bugfix:1944
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/reorganize_tests:1827
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset-new-refactor:1766
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_2_electric_boogaloo:2175
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_cleanup:2102
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3606
fe160bb6-dc1c-0410-9f2b-d64a711b54a5:/local/DBIC-trunk-0.08:10510
   + 168d5346-440b-0410-b799-f706be625ff1:/DBIx-Class-current:2207
462d4d0c-b505-0410-bf8e-ce8f877b3390:/local/bast/DBIx-Class:3159
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/branches/on_disconnect_do:3694
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/DBIx-Class/0.08/trunk:3975
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-C3:318
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-current:2222
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-joins:173
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class-resultset:570
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/datetime:1716
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_compat:1855
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/find_unique_query_fixes:2142
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/inflate:1988
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/many_to_many:2025
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/re_refactor_bugfix:1944
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/reorganize_tests:1827
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset-new-refactor:1766
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_2_electric_boogaloo:2175
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/resultset_cleanup:2102
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/branches/DBIx-Class/sqlt_tests_refactor:2043
bd8105ee-0ff8-0310-8827-fb3f25b6796d:/trunk/DBIx-Class:3606
fe160bb6-dc1c-0410-9f2b-d64a711b54a5:/local/DBIC-trunk-0.08:10510

Modified: DBIx-Class/0.08/branches/versioned_enhancements/Changes
===================================================================
--- DBIx-Class/0.08/branches/versioned_enhancements/Changes	2008-01-30 14:25:32 UTC (rev 3991)
+++ DBIx-Class/0.08/branches/versioned_enhancements/Changes	2008-01-30 16:27:24 UTC (rev 3992)
@@ -1,13 +1,16 @@
 Revision history for DBIx::Class
 
+        - Versioning refactored
 
+0.08009 2008-01-20 13:30
+        - Made search_rs smarter about when to preserve the cache to fix
+          mm prefetch usage
         - Added Storage::DBI subclass for MSSQL over ODBC. 
         - Added freeze, thaw and dclone methods to Schema so that thawed
           objects will get re-attached to the schema.
         - Moved dbicadmin to JSON::Any wrapped JSON.pm for a sane API
         - introduced DBIx::Class::set_inflated_columns
         - DBIx::Class::Row::copy uses set_inflated_columns
-        - Versioning refactored
 
 0.08008 2007-11-16 14:30:00
         - Fixed join merging bug (test from Zby)

Modified: DBIx-Class/0.08/branches/versioned_enhancements/Makefile.PL
===================================================================
--- DBIx-Class/0.08/branches/versioned_enhancements/Makefile.PL	2008-01-30 14:25:32 UTC (rev 3991)
+++ DBIx-Class/0.08/branches/versioned_enhancements/Makefile.PL	2008-01-30 16:27:24 UTC (rev 3992)
@@ -16,7 +16,7 @@
 requires 'Module::Find'              => 0;
 requires 'Class::Inspector'          => 0;
 requires 'Class::Accessor::Grouped'  => 0.05002;
-requires 'JSON'                      => 1.00; 
+requires 'JSON::Any'                 => 1.00; 
 requires 'Scope::Guard'              => 0.03;
 
 # Perl 5.8.0 doesn't have utf8::is_utf8()

Modified: DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class/Manual/Joining.pod
===================================================================
--- DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class/Manual/Joining.pod	2008-01-30 14:25:32 UTC (rev 3991)
+++ DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class/Manual/Joining.pod	2008-01-30 16:27:24 UTC (rev 3992)
@@ -165,7 +165,7 @@
 
   join => [ 'room', 'room' ]
 
-The aliases are: C<room_1> and C<room_2>.
+The aliases are: C<room> and C<room_2>.
 
 =cut
 

Modified: DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class/ResultClass/HashRefInflator.pm
===================================================================
--- DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class/ResultClass/HashRefInflator.pm	2008-01-30 14:25:32 UTC (rev 3991)
+++ DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class/ResultClass/HashRefInflator.pm	2008-01-30 16:27:24 UTC (rev 3992)
@@ -1,5 +1,8 @@
 package DBIx::Class::ResultClass::HashRefInflator;
 
+use strict;
+use warnings;
+
 =head1 NAME
 
 DBIx::Class::ResultClass::HashRefInflator
@@ -61,7 +64,7 @@
     # related sources.
 
     # to avoid emtpy has_many rels contain one empty hashref
-    return if (not keys %$me);
+    return undef if (not keys %$me);
 
     my $def;
 
@@ -71,13 +74,14 @@
             last;
         }
     }
-    return unless $def;
+    return undef unless $def;
 
     return { %$me,
         map {
           ( $_ =>
-             ref($rest->{$_}[0]) eq 'ARRAY' ? [ map { mk_hash(@$_) } @{$rest->{$_}} ]
-                                            : mk_hash( @{$rest->{$_}} )
+             ref($rest->{$_}[0]) eq 'ARRAY'
+                 ? [ grep defined, map mk_hash(@$_), @{$rest->{$_}} ]
+                 : mk_hash( @{$rest->{$_}} )
           )
         } keys %$rest
     };

Modified: DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class/ResultSet.pm
===================================================================
--- DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class/ResultSet.pm	2008-01-30 14:25:32 UTC (rev 3991)
+++ DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class/ResultSet.pm	2008-01-30 16:27:24 UTC (rev 3992)
@@ -11,6 +11,7 @@
 use Storable;
 use DBIx::Class::ResultSetColumn;
 use DBIx::Class::ResultSourceHandle;
+use List::Util ();
 use base qw/DBIx::Class/;
 
 __PACKAGE__->mk_group_accessors('simple' => qw/result_class _source_handle/);
@@ -168,18 +169,26 @@
 sub search_rs {
   my $self = shift;
 
-  my $rows;
-
-  unless (@_) {                 # no search, effectively just a clone
-    $rows = $self->get_cache;
-  }
-
   my $attrs = {};
   $attrs = pop(@_) if @_ > 1 and ref $_[$#_] eq 'HASH';
   my $our_attrs = { %{$self->{attrs}} };
   my $having = delete $our_attrs->{having};
   my $where = delete $our_attrs->{where};
 
+  my $rows;
+
+  my %safe = (alias => 1, cache => 1);
+
+  unless (
+    (@_ && defined($_[0])) # @_ == () or (undef)
+    || 
+    (keys %$attrs # empty attrs or only 'safe' attrs
+    && List::Util::first { !$safe{$_} } keys %$attrs)
+  ) {
+    # no search, effectively just a clone
+    $rows = $self->get_cache;
+  }
+
   my $new_attrs = { %{$our_attrs}, %{$attrs} };
 
   # merge new attrs into inherited

Modified: DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class/Row.pm
===================================================================
--- DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class/Row.pm	2008-01-30 14:25:32 UTC (rev 3991)
+++ DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class/Row.pm	2008-01-30 16:27:24 UTC (rev 3992)
@@ -281,7 +281,7 @@
 required.
 
 Also takes an options hashref of C<< column_name => value> pairs >> to update
-first. But be awawre that the hashref will be passed to
+first. But be aware that the hashref will be passed to
 C<set_inflated_columns>, which might edit it in place, so dont rely on it being
 the same after a call to C<update>.  If you need to preserve the hashref, it is
 sufficient to pass a shallow copy to C<update>, e.g. ( { %{ $href } } )
@@ -767,7 +767,7 @@
 =head2 id
 
 Returns the primary key(s) for a row. Can't be called as a class method.
-Actually implemented in L<DBIx::Class::Pk>
+Actually implemented in L<DBIx::Class::PK>
 
 =head2 discard_changes
 
@@ -776,7 +776,7 @@
 
 This method can also be used to refresh from storage, retrieving any
 changes made since the row was last read from storage. Actually
-implemented in L<DBIx::Class::Pk>
+implemented in L<DBIx::Class::PK>
 
 =cut
 

Modified: DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm
===================================================================
--- DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm	2008-01-30 14:25:32 UTC (rev 3991)
+++ DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm	2008-01-30 16:27:24 UTC (rev 3992)
@@ -38,6 +38,14 @@
     return { limit_dialect => 'Top', %{$self->{_sql_maker_opts}||{}} };
 }
 
+sub build_datetime_parser {
+  my $self = shift;
+  my $type = "DateTime::Format::Strptime";
+  eval "use ${type}";
+  $self->throw_exception("Couldn't load ${type}: $@") if $@;
+  return $type->new( pattern => '%F %T' );
+}
+
 1;
 
 __END__
@@ -72,6 +80,11 @@
 
 =head2 sqlt_type
 
+=head2 build_datetime_parser
+
+The resulting parser handles the MSSQL C<DATETIME> type, but is almost
+certainly not sufficient for the other MSSQL 2008 date/time types.
+
 =head1 AUTHORS
 
 Marc Mims C<< <marc at questright.com> >>

Modified: DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class.pm
===================================================================
--- DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class.pm	2008-01-30 14:25:32 UTC (rev 3991)
+++ DBIx-Class/0.08/branches/versioned_enhancements/lib/DBIx/Class.pm	2008-01-30 16:27:24 UTC (rev 3992)
@@ -24,7 +24,7 @@
 # i.e. first release of 0.XX *must* be 0.XX000. This avoids fBSD ports
 # brain damage and presumably various other packaging systems too
 
-$VERSION = '0.08008';
+$VERSION = '0.08009';
 
 sub MODIFY_CODE_ATTRIBUTES {
   my ($class,$code, at attrs) = @_;

Modified: DBIx-Class/0.08/branches/versioned_enhancements/script/dbicadmin
===================================================================
--- DBIx-Class/0.08/branches/versioned_enhancements/script/dbicadmin	2008-01-30 14:25:32 UTC (rev 3991)
+++ DBIx-Class/0.08/branches/versioned_enhancements/script/dbicadmin	2008-01-30 16:27:24 UTC (rev 3992)
@@ -4,7 +4,7 @@
 
 use Getopt::Long;
 use Pod::Usage;
-use JSON::Any qw(JSON);
+use JSON::Any;
 
 
 my $json = JSON::Any->new(allow_barekey => 1, allow_singlequote => 1);

Modified: DBIx-Class/0.08/branches/versioned_enhancements/t/76joins.t
===================================================================
--- DBIx-Class/0.08/branches/versioned_enhancements/t/76joins.t	2008-01-30 14:25:32 UTC (rev 3991)
+++ DBIx-Class/0.08/branches/versioned_enhancements/t/76joins.t	2008-01-30 16:27:24 UTC (rev 3992)
@@ -247,12 +247,8 @@
 
 is($cd->producers->first->name, 'Matt S Trout', 'many_to_many accessor ok');
 
-TODO: {
-  local $TODO = 'use prefetched values for many_to_many accessor';
+is($queries, 1, 'many_to_many accessor with nested prefetch ran exactly 1 query');
 
-  is($queries, 1, 'many_to_many accessor with nested prefetch ran exactly 1 query');
-}
-
 $queries = 0;
 
 my $producers = $cd->search_related('cd_to_producer')->search_related('producer');

Modified: DBIx-Class/0.08/branches/versioned_enhancements/t/89dbicadmin.t
===================================================================
--- DBIx-Class/0.08/branches/versioned_enhancements/t/89dbicadmin.t	2008-01-30 14:25:32 UTC (rev 3991)
+++ DBIx-Class/0.08/branches/versioned_enhancements/t/89dbicadmin.t	2008-01-30 16:27:24 UTC (rev 3992)
@@ -8,8 +8,8 @@
 
 my $schema = DBICTest->init_schema();
 
-eval 'require JSON';
-plan skip_all => 'Install JSON to run this test' if ($@);
+eval 'require JSON::Any';
+plan skip_all => 'Install JSON::Any to run this test' if ($@);
 
 eval 'require Text::CSV_XS';
 if ($@) {




More information about the Bast-commits mailing list