[svn:p5ee] r8749 - p5ee/trunk/App-Repository/lib/App/Repository

[email protected]
Newsgroups perl.cvs.p5ee
Message-ID <[email protected]>
Author: spadkins
Date: Mon Jan 29 15:05:36 2007
New Revision: 8749

Modified:
   p5ee/trunk/App-Repository/lib/App/Repository/MySQL.pm

Log:
insert_rows(): allow the update options to update only a subset of all of the inserted columns

Modified: p5ee/trunk/App-Repository/lib/App/Repository/MySQL.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/Repository/MySQL.pm	(original)
+++ p5ee/trunk/App-Repository/lib/App/Repository/MySQL.pm	Mon Jan 29 15:05:36 2007
@@ -189,11 +189,14 @@
         }
     }
     if (!$options->{replace} && $options->{update}) {
+        my $update = $options->{update};
         $sql .= "on duplicate key update";
         for ($colnum = 0; $colnum <= $#$cols; $colnum++) {
             $col = $cols->[$colnum];
-            $sql .= "," if ($colnum > 0);
-            $sql .= "\n   $col = values($col)";
+            if (!ref($update) || $update->{$col}) {
+                $sql .= "," if ($colnum > 0);
+                $sql .= "\n   $col = values($col)";
+            }
         }
         $sql .= "\n";
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.