r20506 - in /branches/upstream/librose-db-object-perl/current: ./ lib/Rose/DB/ lib/Rose/DB/Object/ lib/Rose/DB/Object/MakeMethods/ lib/Rose/DB/Object/Metadata/Relationship/ t/

eloy at users.alioth.debian.org eloy at users.alioth.debian.org
Thu May 29 09:47:39 UTC 2008


Author: eloy
Date: Thu May 29 09:47:39 2008
New Revision: 20506

URL: http://svn.debian.org/wsvn/?sc=1&rev=20506
Log:
[svn-upgrade] Integrating new upstream version, librose-db-object-perl (0.770)

Modified:
    branches/upstream/librose-db-object-perl/current/Changes
    branches/upstream/librose-db-object-perl/current/META.yml
    branches/upstream/librose-db-object-perl/current/Makefile.PL
    branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object.pm
    branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Constants.pm
    branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Loader.pm
    branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/MakeMethods/Generic.pm
    branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Metadata/Relationship/ManyToMany.pm
    branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Metadata/Relationship/OneToMany.pm
    branches/upstream/librose-db-object-perl/current/t/00-warning.t
    branches/upstream/librose-db-object-perl/current/t/db-object-foreign-key-auto.t
    branches/upstream/librose-db-object-perl/current/t/db-object-loader.t
    branches/upstream/librose-db-object-perl/current/t/db-object-relationship.t
    branches/upstream/librose-db-object-perl/current/t/make-modules.t
    branches/upstream/librose-db-object-perl/current/t/test-lib.pl

Modified: branches/upstream/librose-db-object-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/librose-db-object-perl/current/Changes?rev=20506&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/Changes (original)
+++ branches/upstream/librose-db-object-perl/current/Changes Thu May 29 09:47:39 2008
@@ -1,3 +1,16 @@
+0.770 (05.28.2008) - John Siracusa <siracusa at gmail.com>
+
+    * Added "iterator" method type, similar to "find", to OneToMany
+      and ManyToMany.  (Patch by Peter Karman - peknet at gmail.com)
+    * Updated the Loader documentation to describe an important 
+      consideration when regenerating modules with make_modules().
+    * Improved error propagation in relationship methods.  (Suggested
+      by Wiggins d'Anconia)
+    * Skip the interactive part of the test suite when the
+      AUTOMATED_TESTING environment variable is set.
+    * Test suite now accounts for versions of DBD::mysql that predate
+      the mysql_is_auto_increment column attribute.
+
 0.769 (04.01.2008) - John Siracusa <siracusa at gmail.com>
 
     * Improved the default singular/plural conversion rules in the

Modified: branches/upstream/librose-db-object-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/librose-db-object-perl/current/META.yml?rev=20506&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/META.yml (original)
+++ branches/upstream/librose-db-object-perl/current/META.yml Thu May 29 09:47:39 2008
@@ -1,13 +1,13 @@
 --- #YAML:1.0
 name:                Rose-DB-Object
-version:             0.769
+version:             0.770
 abstract:            ~
 license:             ~
 author:              ~
 generated_by:        ExtUtils::MakeMaker version 6.44
 distribution_type:   module
 requires:     
-    Bit::Vector::Overload:         0
+    Bit::Vector:                   0
     Clone:                         0.20
     Cwd:                           0
     DateTime:                      0

Modified: branches/upstream/librose-db-object-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/librose-db-object-perl/current/Makefile.PL?rev=20506&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/Makefile.PL (original)
+++ branches/upstream/librose-db-object-perl/current/Makefile.PL Thu May 29 09:47:39 2008
@@ -15,7 +15,7 @@
                 'DateTime'              => 0,
                 'Time::Clock'           => 0,
                 'Test::More'            => 0,
-                'Bit::Vector::Overload' => 0,
+                'Bit::Vector'           => 0,
                 'Scalar::Util'          => 0,
                 'List::MoreUtils'       => 0,
                 'Math::BigInt'          => '1.77',

Modified: branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object.pm
URL: http://svn.debian.org/wsvn/branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object.pm?rev=20506&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object.pm (original)
+++ branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object.pm Thu May 29 09:47:39 2008
@@ -13,9 +13,10 @@
 use Rose::DB::Object::Manager;
 use Rose::DB::Object::Constants qw(:all);
 use Rose::DB::Constants qw(IN_TRANSACTION);
+use Rose::DB::Object::Exception;
 use Rose::DB::Object::Util();
 
-our $VERSION = '0.769';
+our $VERSION = '0.770';
 
 our $Debug = 0;
 
@@ -223,11 +224,16 @@
       {
         @key_columns = $meta->primary_key_column_names;
 
-        $self->error("Cannot load " . ref($self) . " without a primary key (" .
-                     join(', ', @key_columns) . ') with ' .
-                     (@key_columns > 1 ? 'non-null values in all columns' : 
-                                         'a non-null value') .
-                     ' or another unique key with at least one non-null value.');
+        my $e = 
+          Rose::DB::Object::Exception->new(
+            message => "Cannot load " . ref($self) . " without a primary key (" .
+                       join(', ', @key_columns) . ') with ' .
+                       (@key_columns > 1 ? 'non-null values in all columns' : 
+                                           'a non-null value') .
+                       ' or another unique key with at least one non-null value.',
+            code => EXCEPTION_CODE_NO_KEY);
+
+        $self->error($e);
 
         $meta->handle_error($self);
         return 0;
@@ -2290,7 +2296,7 @@
 
 =head1 CONTRIBUTORS
 
-Bradley C Bailey, Graham Barr, David Christensen, Lucian Dragus, Justin Ellison, Perrin Harkins, Cees Hek, Michael Reece, Teodor Zlatanov
+Bradley C Bailey, Graham Barr, David Christensen, Lucian Dragus, Justin Ellison, Perrin Harkins, Cees Hek, Peter Karman, Michael Reece, Teodor Zlatanov
 
 =head1 AUTHOR
 

Modified: branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Constants.pm
URL: http://svn.debian.org/wsvn/branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Constants.pm?rev=20506&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Constants.pm (original)
+++ branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Constants.pm Thu May 29 09:47:39 2008
@@ -10,7 +10,8 @@
 our @EXPORT_OK = 
   qw(PRIVATE_PREFIX META_ATTR_NAME ON_SAVE_ATTR_NAME 
      LOADED_FROM_DRIVER FLAG_DB_IS_PRIVATE MODIFIED_COLUMNS SET_COLUMNS 
-     STATE_IN_DB STATE_LOADING STATE_SAVING STATE_CLONING);
+     STATE_IN_DB STATE_LOADING STATE_SAVING STATE_CLONING
+     EXCEPTION_CODE_NO_KEY);
 
 our %EXPORT_TAGS = (all => \@EXPORT_OK);
 
@@ -26,4 +27,6 @@
 use constant STATE_SAVING       => PRIVATE_PREFIX . '_saving';
 use constant STATE_CLONING      => STATE_SAVING;
 
+use constant EXCEPTION_CODE_NO_KEY => 5; # arbitrary
+
 1;

Modified: branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Loader.pm
URL: http://svn.debian.org/wsvn/branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Loader.pm?rev=20506&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Loader.pm (original)
+++ branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Loader.pm Thu May 29 09:47:39 2008
@@ -17,7 +17,7 @@
 use Rose::Object;
 our @ISA = qw(Rose::Object);
 
-our $VERSION = '0.764';
+our $VERSION = '0.770';
 
 our $Debug = 0;
 
@@ -1348,7 +1348,13 @@
 
 Automatically create L<Rose::DB::Object> and (optionally) L<Rose::DB::Object::Manager> subclasses for some or all of the tables in a database, then create Perl module (*.pm) files for each class.
 
-This method calls L<make_classes|/make_classes> to make the actual classes, and therefore takes all of the same parameters, with several additions.
+This method calls L<make_classes|/make_classes> to make the actual classes.
+
+B<Note:> If you are trying to regenerate a set of module files that already exist in the target C<module_dir>, please make sure that this C<module_dir> is I<not> in your C<@INC> path.  (That is, make sure it is not in the set of paths that perl will search when looking for module files in response to a C<use> or C<require> statement.)  More generally, you must make sure that existing versions of the modules you are attempting to generate are not in your C<@INC> path.
+
+(If you do not do this, when L<make_classes|/make_classes> makes a class and looks for a related class, it will find and load the previously generated C<.pm> file, which will then cause L<make_classes|/make_classes> to skip that class later when it sees that it already exists in memory.  And if L<make_classes|/make_classes> skips it, L<make_modules|/make_modules> will never see it and therefore will never regenerate the C<.pm> file.)
+
+This method takes all of the same parameters as L<make_classes|/make_classes>, with several additions:
 
 =over 4
 

Modified: branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/MakeMethods/Generic.pm
URL: http://svn.debian.org/wsvn/branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/MakeMethods/Generic.pm?rev=20506&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/MakeMethods/Generic.pm (original)
+++ branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/MakeMethods/Generic.pm Thu May 29 09:47:39 2008
@@ -14,11 +14,12 @@
 use Rose::DB::Constants qw(IN_TRANSACTION);
 use Rose::DB::Object::Constants 
   qw(PRIVATE_PREFIX FLAG_DB_IS_PRIVATE STATE_IN_DB STATE_LOADING
-     STATE_SAVING ON_SAVE_ATTR_NAME MODIFIED_COLUMNS SET_COLUMNS);
+     STATE_SAVING ON_SAVE_ATTR_NAME MODIFIED_COLUMNS SET_COLUMNS
+     EXCEPTION_CODE_NO_KEY);
 
 use Rose::DB::Object::Util qw(column_value_formatted_key);
 
-our $VERSION = '0.7671';
+our $VERSION = '0.770';
 
 our $Debug = 0;
 
@@ -2195,8 +2196,19 @@
             my $ret;
 
             # Ignore any errors due to missing primary keys
+            # XXX: TODO: only eat the missing pk error?
             local $dbh->{'PrintError'} = 0;
             eval { $ret = $object->load(speculative => 1) };
+
+            if(my $error = $@)
+            {
+              # ...but re-throw all other errors
+              unless(UNIVERSAL::isa($error, 'Rose::DB::Object::Exception') &&
+                     $error->code == EXCEPTION_CODE_NO_KEY)
+              {
+                die $error;
+              }
+            }
 
             unless($ret)
             {
@@ -2397,6 +2409,16 @@
               local $dbh->{'PrintError'} = 0;
               eval { $ret = $object->load(speculative => 1) };
 
+              if(my $error = $@)
+              {
+                # ...but re-throw all other errors
+                unless(UNIVERSAL::isa($error, 'Rose::DB::Object::Exception') &&
+                       $error->code == EXCEPTION_CODE_NO_KEY)
+                {
+                  die $error;
+                }
+              }
+
               unless($ret)
               {
                 $object->save(%$args) or die $object->error;
@@ -2940,9 +2962,16 @@
       return $count;
     };
   }
-  elsif($interface eq 'find')
+  elsif($interface eq 'find' || $interface eq 'iterator')
   {
-    my $cache_key = PRIVATE_PREFIX . '_' . $name;
+    my $cache_key = PRIVATE_PREFIX . ":$interface:$name";
+
+    my $is_iterator = $interface eq 'iterator' ? 1 : 0;
+
+    if($is_iterator && $ft_method eq 'get_objects')
+    {
+      $ft_method = 'get_objects_iterator';
+    }
 
     $methods{$name} = sub
     {
@@ -3052,10 +3081,13 @@
 
       if($@ || !$objs)
       {
-        $self->error("Could not find $ft_class objects - " . $ft_manager->error);
+        $self->error("Could not ", ($is_iterator ? 'get iterator for' : 'find'),
+                     " $ft_class objects - " . $ft_manager->error);
         $self->meta->handle_error($self);
         return wantarray ? () : $objs;
       }
+
+      return $objs  if($is_iterator);
 
       $self->{$cache_key} = $objs  if($cache);
 
@@ -3290,7 +3322,7 @@
             {
               my $dbh = $object->dbh;
 
-              # It's okay if this fails (e.g., if the primary key is undefined)
+              # It's okay if this fails because the key(s) is/are undefined
               local $dbh->{'PrintError'} = 0;
               eval
               {
@@ -3300,6 +3332,16 @@
                   $object->init(%map);
                 }
               };
+
+              if(my $error = $@)
+              {
+                # ...but re-throw all other errors
+                unless(UNIVERSAL::isa($error, 'Rose::DB::Object::Exception') &&
+                       $error->code == EXCEPTION_CODE_NO_KEY)
+                {
+                  die $error;
+                }
+              }
             }
 
             # Save the object
@@ -3562,7 +3604,7 @@
             {
               my $dbh = $object->dbh;
 
-              # It's okay if this fails (e.g., if the primary key is undefined)
+              # It's okay if this fails because the key(s) is/are undefined
               local $dbh->{'PrintError'} = 0;
               eval
               {
@@ -3572,6 +3614,16 @@
                   $object->init(%map);
                 }
               };
+
+              if(my $error = $@)
+              {
+                # ...but re-throw all other errors
+                unless(UNIVERSAL::isa($error, 'Rose::DB::Object::Exception') &&
+                       $error->code == EXCEPTION_CODE_NO_KEY)
+                {
+                  die $error;
+                }
+              }
             }
 
             # Save the object
@@ -3943,6 +3995,16 @@
           local $dbh->{'PrintError'} = 0;
           eval { $ret = $object->load(speculative => 1) };
 
+          if(my $error = $@)
+          {
+            # ...but re-throw all other errors
+            unless(UNIVERSAL::isa($error, 'Rose::DB::Object::Exception') &&
+                   $error->code == EXCEPTION_CODE_NO_KEY)
+            {
+              die $error;
+            }
+          }
+
           unless($ret)
           {
             $object->save or die $object->error;
@@ -4062,6 +4124,16 @@
           # Ignore any errors due to missing primary keys
           local $dbh->{'PrintError'} = 0;
           eval { $ret = $object->load(speculative => 1) };
+
+          if(my $error = $@)
+          {
+            # ...but re-throw all other errors
+            unless(UNIVERSAL::isa($error, 'Rose::DB::Object::Exception') &&
+                   $error->code == EXCEPTION_CODE_NO_KEY)
+            {
+              die $error;
+            }
+          }
 
           unless($ret)
           {
@@ -4375,9 +4447,16 @@
     }
   }
 
-  if($interface eq 'find')
+  if($interface eq 'find' || $interface eq 'iterator')
   {
-    my $cache_key = PRIVATE_PREFIX . '_' . $name;
+    my $cache_key = PRIVATE_PREFIX . ":$interface:$name";
+
+    my $is_iterator = $interface eq 'iterator' ? 1 : 0;
+
+    if($is_iterator && $map_method eq 'get_objects')
+    {
+      $map_method = 'get_objects_iterator';
+    }
 
     $methods{$name} = sub
     {
@@ -4510,6 +4589,29 @@
           }
           @$objs
         ];
+      }
+      elsif($is_iterator)
+      {
+        my $next_code = $objs->_next_code;
+
+        my $post_proc = sub
+        {
+          my($self, $map_object) = @_;
+          return $map_object->$map_to();
+        };
+
+        $objs->_next_code
+        (
+          sub
+          {
+            my $self = shift;
+            my $object = $next_code->($self, @_);
+            return $object  unless($object);
+            return $post_proc->($self, $object);
+          }
+        );
+
+        return $objs;      
       }
       else
       {
@@ -4876,9 +4978,19 @@
             {
               my $dbh = $object->dbh;
 
-              # It's okay if this fails (e.g., if the primary key is undefined)
+              # It's okay if this fails because the key(s) is/are undefined
               local $dbh->{'PrintError'} = 0;
               eval { $in_db = $object->load(speculative => 1) };
+
+              if(my $error = $@)
+              {
+                # ...but re-throw all other errors
+                unless(UNIVERSAL::isa($error, 'Rose::DB::Object::Exception') &&
+                       $error->code == EXCEPTION_CODE_NO_KEY)
+                {
+                  die $error;
+                }
+              }
             }
 
             # Save the object, if necessary
@@ -4916,9 +5028,19 @@
             {
               my $dbh = $map_record->dbh;
 
-              # It's okay if this fails (e.g., if the primary key is undefined)
+              # It's okay if this fails because the key(s) is/are undefined
               local $dbh->{'PrintError'} = 0;
               eval { $in_db = $map_record->load(speculative => 1) };
+
+              if(my $error = $@)
+              {
+                # ...but re-throw all other errors
+                unless(UNIVERSAL::isa($error, 'Rose::DB::Object::Exception') &&
+                       $error->code == EXCEPTION_CODE_NO_KEY)
+                {
+                  die $error;
+                }
+              }
             }
 
             # Save the map record, if necessary
@@ -5136,9 +5258,19 @@
             {
               my $dbh = $object->dbh;
 
-              # It's okay if this fails (e.g., if the primary key is undefined)
+              # It's okay if this fails because the key(s) is/are undefined
               local $dbh->{'PrintError'} = 0;
               eval { $in_db = $object->load(speculative => 1) };
+
+              if(my $error = $@)
+              {
+                # ...but re-throw all other errors
+                unless(UNIVERSAL::isa($error, 'Rose::DB::Object::Exception') &&
+                       $error->code == EXCEPTION_CODE_NO_KEY)
+                {
+                  die $error;
+                }
+              }
             }
 
             # Save the object, if necessary
@@ -5184,9 +5316,19 @@
             {
               my $dbh = $map_record->dbh;
 
-              # It's okay if this fails (e.g., if the primary key is undefined)
+              # It's okay if this fails because the key(s) is/are undefined
               local $dbh->{'PrintError'} = 0;
               eval { $in_db = $map_record->load(speculative => 1) };
+
+              if(my $error = $@)
+              {
+                # ...but re-throw all other errors
+                unless(UNIVERSAL::isa($error, 'Rose::DB::Object::Exception') &&
+                       $error->code == EXCEPTION_CODE_NO_KEY)
+                {
+                  die $error;
+                }
+              }
             }
 
             # Save the map record, if necessary
@@ -5396,9 +5538,19 @@
           {
             my $dbh = $object->dbh;
 
-            # It's okay if this fails (e.g., if the primary key is undefined)
+            # It's okay if this fails because the key(s) is/are undefined
             local $dbh->{'PrintError'} = 0;
             eval { $in_db = $object->load(speculative => 1) };
+
+            if(my $error = $@)
+            {
+              # ...but re-throw all other errors
+              unless(UNIVERSAL::isa($error, 'Rose::DB::Object::Exception') &&
+                     $error->code == EXCEPTION_CODE_NO_KEY)
+              {
+                die $error;
+              }
+            }
           }
 
           # Save the object, if necessary
@@ -5426,9 +5578,19 @@
           {
             my $dbh = $map_record->dbh;
 
-            # It's okay if this fails (e.g., if the primary key is undefined)
+            # It's okay if this fails because the key(s) is/are undefined
             local $dbh->{'PrintError'} = 0;
             eval { $in_db = $map_record->load(speculative => 1) };
+
+            if(my $error = $@)
+            {
+              # ...but re-throw all other errors
+              unless(UNIVERSAL::isa($error, 'Rose::DB::Object::Exception') &&
+                     $error->code == EXCEPTION_CODE_NO_KEY)
+              {
+                die $error;
+              }
+            }
           }
 
           # Save the map record, if necessary
@@ -5526,9 +5688,19 @@
           {
             my $dbh = $object->dbh;
 
-            # It's okay if this fails (e.g., if the primary key is undefined)
+            # It's okay if this fails because the key(s) is/are undefined
             local $dbh->{'PrintError'} = 0;
             eval { $in_db = $object->load(speculative => 1) };
+
+            if(my $error = $@)
+            {
+              # ...but re-throw all other errors
+              unless(UNIVERSAL::isa($error, 'Rose::DB::Object::Exception') &&
+                     $error->code == EXCEPTION_CODE_NO_KEY)
+              {
+                die $error;
+              }
+            }
           }
 
           # Save the object, if necessary
@@ -5556,9 +5728,19 @@
           {
             my $dbh = $map_record->dbh;
 
-            # It's okay if this fails (e.g., if the primary key is undefined)
+            # It's okay if this fails because the key(s) is/are undefined
             local $dbh->{'PrintError'} = 0;
             eval { $in_db = $map_record->load(speculative => 1) };
+
+            if(my $error = $@)
+            {
+              # ...but re-throw all other errors
+              unless(UNIVERSAL::isa($error, 'Rose::DB::Object::Exception') &&
+                     $error->code == EXCEPTION_CODE_NO_KEY)
+              {
+                die $error;
+              }
+            }
           }
 
           # Save the map record, if necessary
@@ -6500,6 +6682,10 @@
 The fetch may fail for several reasons.  The fetch will not even be attempted if any of the key attributes in the current object are undefined.  Instead, undef (in scalar context) or an empty list (in list context) will be returned.  If the call to C<manager_class>'s C<manager_method> method returns false, the behavior is determined by the L<metadata object|Rose::DB::Object/meta>'s L<error_mode|Rose::DB::Object::Metadata/error_mode>.  If the mode is C<return>, that false value (in scalar context) or an empty list (in list context) is returned.
 
 If the fetch succeeds, a list (in list context) or a reference to the array of objects (in scalar context) is returned.  (If the fetch finds zero objects, the list or array reference will simply be empty.  This is still considered success.)
+
+=item B<iterator>
+
+Behaves just like B<find> but returns an L<iterator|Rose::DB::Object::Iterator> rather than an array or arrayref.
 
 =item B<get_set>
 
@@ -6996,6 +7182,10 @@
 
 If the fetch succeeds, a list (in list context) or a reference to the array of objects (in scalar context) is returned.  (If the fetch finds zero objects, the list or array reference will simply be empty.  This is still considered success.)
 
+=item B<iterator>
+
+Behaves just like B<find> but returns an L<iterator|Rose::DB::Object::Iterator> rather than an array or arrayref.
+
 =item B<get_set>
 
 Creates a method that will attempt to fetch L<Rose::DB::Object>-derived objects that are related to the current object through the C<map_class>.

Modified: branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Metadata/Relationship/ManyToMany.pm
URL: http://svn.debian.org/wsvn/branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Metadata/Relationship/ManyToMany.pm?rev=20506&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Metadata/Relationship/ManyToMany.pm (original)
+++ branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Metadata/Relationship/ManyToMany.pm Thu May 29 09:47:39 2008
@@ -14,7 +14,7 @@
 
 use Rose::DB::Object::Constants qw(PRIVATE_PREFIX);
 
-our $VERSION = '0.766';
+our $VERSION = '0.770';
 
 our $Debug = 0;
 
@@ -70,6 +70,13 @@
     class     => 'Rose::DB::Object::MakeMethods::Generic',
     type      => 'objects_by_map',
     interface => 'find',
+  },
+
+  iterator =>
+  {
+    class     => 'Rose::DB::Object::MakeMethods::Generic',
+    type      => 'objects_by_map',
+    interface => 'iterator',
   },
 
   get_set =>
@@ -187,6 +194,10 @@
   elsif($type eq 'find')
   {
     return 'find_' . $self->name;
+  }
+  elsif($type eq 'iterator')
+  {
+    return $self->name . '_iterator';
   }
   elsif($type eq 'count')
   {
@@ -641,6 +652,10 @@
 
 L<Rose::DB::Object::MakeMethods::Generic>, L<objects_by_key|Rose::DB::Object::MakeMethods::Generic/objects_by_map>, C<interface =E<gt> 'find'> ...
 
+=item C<iterator>
+
+L<Rose::DB::Object::MakeMethods::Generic>, L<objects_by_key|Rose::DB::Object::MakeMethods::Generic/objects_by_map>, C<interface =E<gt> 'iterator'> ...
+
 =item C<get_set>
 
 L<Rose::DB::Object::MakeMethods::Generic>, L<objects_by_map|Rose::DB::Object::MakeMethods::Generic/objects_by_map>, 

Modified: branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Metadata/Relationship/OneToMany.pm
URL: http://svn.debian.org/wsvn/branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Metadata/Relationship/OneToMany.pm?rev=20506&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Metadata/Relationship/OneToMany.pm (original)
+++ branches/upstream/librose-db-object-perl/current/lib/Rose/DB/Object/Metadata/Relationship/OneToMany.pm Thu May 29 09:47:39 2008
@@ -12,7 +12,7 @@
 
 our $Debug = 0;
 
-our $VERSION = '0.764';
+our $VERSION = '0.770';
 
 __PACKAGE__->default_auto_method_types(qw(find get_set_on_save add_on_save));
 
@@ -60,6 +60,13 @@
     interface => 'find',
   },
 
+  iterator =>
+  {
+    class     => 'Rose::DB::Object::MakeMethods::Generic',
+    type      => 'objects_by_key',
+    interface => 'iterator',
+  },
+
   get_set =>
   {
     class     => 'Rose::DB::Object::MakeMethods::Generic',
@@ -127,6 +134,10 @@
   elsif($type eq 'find')
   {
     return 'find_' . $self->name;
+  }
+  elsif($type eq 'iterator')
+  {
+    return $self->name . '_iterator';
   }
   elsif($type eq 'count')
   {
@@ -193,6 +204,10 @@
 =item C<find>
 
 L<Rose::DB::Object::MakeMethods::Generic>, L<objects_by_key|Rose::DB::Object::MakeMethods::Generic/objects_by_key>, C<interface =E<gt> 'find'> ...
+
+=item C<iterator>
+
+L<Rose::DB::Object::MakeMethods::Generic>, L<objects_by_key|Rose::DB::Object::MakeMethods::Generic/objects_by_key>, C<interface =E<gt> 'iterator'> ...
 
 =item C<get_set>
 

Modified: branches/upstream/librose-db-object-perl/current/t/00-warning.t
URL: http://svn.debian.org/wsvn/branches/upstream/librose-db-object-perl/current/t/00-warning.t?rev=20506&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/t/00-warning.t (original)
+++ branches/upstream/librose-db-object-perl/current/t/00-warning.t Thu May 29 09:47:39 2008
@@ -72,23 +72,26 @@
 EOF
 }
 
-my %old;
+unless($ENV{'AUTOMATED_TESTING'})
+{
+  my %old;
 
-$old{'ALRM'} = $SIG{'ALRM'} || 'DEFAULT';
+  $old{'ALRM'} = $SIG{'ALRM'} || 'DEFAULT';
 
-eval
-{
-  # Localize so I only have to restore in my catch block
-  local $SIG{'ALRM'} = sub { die 'alarm' };
-  alarm(60);
-  my $res = <STDIN>;
-  alarm(0);
-};
+  eval
+  {
+    # Localize so I only have to restore in my catch block
+    local $SIG{'ALRM'} = sub { die 'alarm' };
+    alarm(60);
+    my $res = <STDIN>;
+    alarm(0);
+  };
 
-if($@ =~ /alarm/)
-{
-  $SIG{'ALRM'} = $old{'ALRM'};
-}    
+  if($@ =~ /alarm/)
+  {
+    $SIG{'ALRM'} = $old{'ALRM'};
+  }
+}
 
 print "1..1\n",
       "ok 1\n";

Modified: branches/upstream/librose-db-object-perl/current/t/db-object-foreign-key-auto.t
URL: http://svn.debian.org/wsvn/branches/upstream/librose-db-object-perl/current/t/db-object-foreign-key-auto.t?rev=20506&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/t/db-object-foreign-key-auto.t (original)
+++ branches/upstream/librose-db-object-perl/current/t/db-object-foreign-key-auto.t Thu May 29 09:47:39 2008
@@ -747,6 +747,8 @@
   no warnings 'once';
   local $Rose::DB::Object::Metadata::Auto::Sort_Columns_Alphabetically = 1;
 
+  my $serial = $o->db->dbh->{'Driver'}{'Version'} >= 4.002 ? 'serial' : 'integer';
+
   is(MyMySQLObject->meta->perl_class_definition(use_setup => 0),
      <<"EOF", "perl_class_definition (trad) 1 - $db_type");
 package MyMySQLObject;
@@ -768,7 +770,7 @@
     fother_id2    => { type => 'integer' },
     fother_id3    => { type => 'integer' },
     fother_id4    => { type => 'integer' },
-    id            => { type => 'serial', not_null => 1 },
+    id            => { type => '$serial', not_null => 1 },
     $set_col
     last_modified => { type => 'datetime' },
     name          => { type => 'varchar', @{[ $no_empty_def ? '' : "default => '', " ]}length => 32, not_null => 1 },
@@ -834,7 +836,7 @@
   fother_id2    => { type => 'integer' },
   fother_id3    => { type => 'integer' },
   fother_id4    => { type => 'integer' },
-  id            => { type => 'serial', not_null => 1 },
+  id            => { type => '$serial', not_null => 1 },
   $set_col
   last_modified => { type => 'datetime' },
   name          => { type => 'varchar', @{[ $no_empty_def ? '' : "default => '', " ]}length => 32, not_null => 1 },

Modified: branches/upstream/librose-db-object-perl/current/t/db-object-loader.t
URL: http://svn.debian.org/wsvn/branches/upstream/librose-db-object-perl/current/t/db-object-loader.t?rev=20506&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/t/db-object-loader.t (original)
+++ branches/upstream/librose-db-object-perl/current/t/db-object-loader.t Thu May 29 09:47:39 2008
@@ -61,9 +61,10 @@
 
   my $pre_init_hook = 0;
 
+  my $db = Rose::DB->new;
   my $loader = 
     Rose::DB::Object::Loader->new(
-      db            => Rose::DB->new,
+      db            => $db,
       class_prefix  => $class_prefix,
       ($db_type eq 'mysql' ? (require_primary_key => 0) : ()),
       pre_init_hook => sub { $pre_init_hook++ });
@@ -121,14 +122,18 @@
 
   if($db_type =~ /^(?:mysql|pg|sqlite)$/)
   {
-    is($product_class->meta->column('id')->type, 'serial', "serial column - $db_type");
+    my $serial =
+      ($db_type ne 'mysql' || $db->dbh->{'Driver'}{'Version'} >= 4.002) ? 
+      'serial' : 'integer';
+
+    is($product_class->meta->column('id')->type, $serial, "serial column - $db_type");
   }
   else
   {
     SKIP: { skip("serial coercion test for $db_type", 1) }
   }
 
-  if($db_type eq 'mysql')
+  if($db_type eq 'mysql' && $db->dbh->{'Driver'}{'Version'} >= 4.002)
   {
     is($price_class->meta->column('id')->type, 'bigserial', "bigserial column - $db_type");
   }

Modified: branches/upstream/librose-db-object-perl/current/t/db-object-relationship.t
URL: http://svn.debian.org/wsvn/branches/upstream/librose-db-object-perl/current/t/db-object-relationship.t?rev=20506&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/t/db-object-relationship.t (original)
+++ branches/upstream/librose-db-object-perl/current/t/db-object-relationship.t Thu May 29 09:47:39 2008
@@ -2,7 +2,7 @@
 
 use strict;
 
-use Test::More tests => 1555;
+use Test::More tests => 1566;
 
 BEGIN 
 {
@@ -4351,7 +4351,7 @@
 
 SKIP: foreach my $db_type ('sqlite')
 {
-  skip("SQLite tests", 433)  unless($HAVE_SQLITE);
+  skip("SQLite tests", 444)  unless($HAVE_SQLITE);
 
   Rose::DB->default_type($db_type);
 
@@ -4602,6 +4602,17 @@
      $colors->[0] eq $colors2->[0],
      "find colors from cache - $db_type");
 
+  ok(my $iterator = $o->colors_iterator, "get colors_iterator - $db_type");
+
+  ok($iterator->isa('Rose::DB::Object::Iterator'),  "colors iterator isa Iterator - $db_type");
+
+  while(my $color = $iterator->next)
+  {
+    ok($color->name, "color has a name (" . $color->name . ") - $db_type");
+  }
+
+  is($iterator->total, 2, "iterator total - $db_type");
+
   my $count = $o->colors_count;
 
   is($count, 2, "count colors 1 - $db_type");
@@ -5088,6 +5099,16 @@
 
   ok($fos2[0] eq $fos[0], "find one to many from_cache 1 - $db_type");
   ok($fos2[1] eq $fos[1], "find one to many from_cache 2 - $db_type");
+  
+  ok(my $o2objects_iterator = $o->other2_objs_iterator, "other2_objs_iterator - $db_type");
+  ok($o2objects_iterator->isa('Rose::DB::Object::Iterator'), "isa Iterator - $db_type");
+
+  while(my $o2i = $o2objects_iterator->next)
+  {
+    ok($o2i->isa('MySQLiteOtherObject2'), "isa MySQLiteOtherObject2 - $db_type");
+  }
+
+  is($o2objects_iterator->total, 3, "MySQLiteOtherObject2 iterator total - $db_type");
 
   $o2 = MySQLiteOtherObject2->new(id => 1)->load(speculative => 1);
   ok($o2 && $o2->pid == $o->id, "set one to many now 7 - $db_type");
@@ -7326,6 +7347,7 @@
         methods =>
         {
           find            => undef,
+          iterator        => undef,
           get_set         => undef,
           get_set_now     => 'other2_objs_now',
           get_set_on_save => 'other2_objs_on_save',
@@ -7382,6 +7404,7 @@
           add_on_save     => 'add_colors_on_save',
           find            => undef,
           count           => undef,
+          iterator        => undef,
         },
       },
 

Modified: branches/upstream/librose-db-object-perl/current/t/make-modules.t
URL: http://svn.debian.org/wsvn/branches/upstream/librose-db-object-perl/current/t/make-modules.t?rev=20506&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/t/make-modules.t (original)
+++ branches/upstream/librose-db-object-perl/current/t/make-modules.t Thu May 29 09:47:39 2008
@@ -27,7 +27,7 @@
 my $Include_Tables = '^(?:' . join('|', 
   qw(product_colors prices products colors vendors)) . ')$';
 $Include_Tables = qr($Include_Tables);
-  
+
 my %Column_Defs =
 (
   pg => 
@@ -79,6 +79,12 @@
   Rose::DB::Object::Metadata->unregister_all_classes;
 
   Rose::DB->default_type($db_type);
+
+  if($db_type eq 'mysql')
+  {
+    my $serial = Rose::DB->new->dbh->{'Driver'}{'Version'} >= 4.002 ? 'serial' : 'integer';
+    $Column_Defs{'mysql'}{'id'} = qq(id        => { type => '$serial', not_null => 1 },);
+  }
 
   my $class_prefix = 'My' . ucfirst($db_type);
 

Modified: branches/upstream/librose-db-object-perl/current/t/test-lib.pl
URL: http://svn.debian.org/wsvn/branches/upstream/librose-db-object-perl/current/t/test-lib.pl?rev=20506&op=diff
==============================================================================
--- branches/upstream/librose-db-object-perl/current/t/test-lib.pl (original)
+++ branches/upstream/librose-db-object-perl/current/t/test-lib.pl Thu May 29 09:47:39 2008
@@ -135,7 +135,11 @@
   # SQLite
   #
 
-  eval { require DBD::SQLite };
+  eval
+  {
+    local $^W = 0;
+    require DBD::SQLite;
+  };
 
   my $version = $DBD::SQLite::VERSION || 0;
 




More information about the Pkg-perl-cvs-commits mailing list