[svn:dbi] r14143 - dbi/trunk/lib/DBD

[email protected]
Newsgroups perl.dbi.changes
Message-ID <[email protected]>
Author: REHSACK
Date: Mon Jun 14 06:37:52 2010
New Revision: 14143

Modified:
   dbi/trunk/lib/DBD/DBM.pm

Log:
Fix bug (UPDATE on INSERT statement)


Modified: dbi/trunk/lib/DBD/DBM.pm
==============================================================================
--- dbi/trunk/lib/DBD/DBM.pm	(original)
+++ dbi/trunk/lib/DBD/DBM.pm	Mon Jun 14 06:37:52 2010
@@ -528,10 +528,10 @@
     return wantarray ? @row : \@row;
 }
 
-# you must define push_row
-# it is called on inserts and updates
+# you must define push_row except insert_new_row and update_specific_row is defined
+# it is called on inserts and updates as primitive
 #
-sub push_row ($$$)
+sub insert_new_row ($$$)
 {
     my ( $self, $data, $row_aryref ) = @_;
     my $meta = $self->{meta};
@@ -539,7 +539,11 @@
     my $nitems = scalar(@{$row_aryref});
     $ncols == $nitems or
         croak "You tried to insert $nitems, but table is created with $ncols columns";
+
     my $key  = shift @$row_aryref;
+    exists($meta->{hash}->{$key}) and
+	croak "Row with PK '$key' already exists";
+
     if ( $meta->{dbm_mldbm} )
     {
         $meta->{hash}->{$key} = $row_aryref;
@@ -1357,22 +1361,6 @@
 See the entire section on L<Table locking and flock()> for gotchas and
 warnings about the use of flock().
 
-=head1 BUGS AND LIMITATIONS
-
-This modules uses hash interfaces of two column file databases. While
-none of supported SQL engines have a support for indices, following
-statements really do the same (even if they mean something completely
-different):
-
-  $sth->do( "insert into foo values (1, 'hello')" );
-
-  # this statement does ...
-  $sth->do( "update foo set v='world' where k=1" );
-  # ... the same as this statement
-  $sth->do( "insert into foo values (1, 'world')" );
-
-This is considered as a bug and might change in a future release.
-
 =head1 GETTING HELP, MAKING SUGGESTIONS, AND REPORTING BUGS
 
 If you need help installing or using DBD::DBM, please write to the DBI
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.