[Bps-public-commit] UNNAMED PROJECT branch, master, updated. cf6f7b7ea8a4d2b76de5618a431921c5f9a5d8bb

jesse jesse at bestpractical.com
Fri Jan 16 09:02:52 EST 2009


The branch, master has been updated
       via  cf6f7b7ea8a4d2b76de5618a431921c5f9a5d8bb (commit)
       via  de4b0bb7b8d1115671e28fc74117ade403959c82 (commit)
       via  bf4c3fa8404774e0e563c6d747cf8c8100a89488 (commit)
      from  65ab6b3418a918aa14a09631380a2e99b8f755e6 (commit)

Summary of changes:
 lib/Prophet/Replica/sqlite.pm |   19 ++++++++++++++-----
 t/luid.t                      |   28 +++++++++++++++++++++++-----
 2 files changed, 37 insertions(+), 10 deletions(-)

- Log -----------------------------------------------------------------
commit bf4c3fa8404774e0e563c6d747cf8c8100a89488
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Fri Jan 16 08:57:05 2009 -0500

    New tests that show how we were losing records in the records table on
    prop update
    
    (Note that this _only_ happened using sqlite and only since about 12
    hours ago)

diff --git a/t/luid.t b/t/luid.t
index 0d184dd..908156a 100644
--- a/t/luid.t
+++ b/t/luid.t
@@ -1,6 +1,6 @@
 use warnings;
 use strict;
-use Test::More tests => 11;
+use Test::More tests => 13;
 
 use File::Temp qw'tempdir';
 
@@ -14,10 +14,10 @@ my $cxn = $cli->handle;
 $cxn->initialize;
 
 my $record = Prophet::Record->new(handle => $cxn, type => 'Empty');
-my $uuid = $record->create(props => {});
+my $uuid = $record->create(props => { which => 'first'});
 my $luid = $record->luid;
-ok($uuid, "got a uuid");
-ok($luid, "got a luid");
+ok($uuid, "got a uuid $uuid");
+ok($luid, "got a luid $luid");
 
 $record = Prophet::Record->new(handle => $cxn, type => 'Empty');
 $record->load(uuid => $uuid);
@@ -29,7 +29,7 @@ is($record->uuid, $uuid, "load accepts an luid");
 is($record->luid, $luid, "same luid after load");
 
 my $record2 = Prophet::Record->new(handle => $cxn, type => 'Empty');
-my $uuid2 = $record2->create(props => {});
+my $uuid2 = $record2->create(props => { which => 'second'});
 my $luid2 = $record2->luid;
 isnt($uuid, $uuid2, "different uuids");
 isnt($luid, $luid2, "different luids");
@@ -38,3 +38,21 @@ $record2 = Prophet::Record->new(handle => $cxn, type => 'Empty');
 $record2->load(luid => $luid2);
 is($record2->uuid, $uuid2, "load accepts an luid");
 is($record2->luid, $luid2, "same luid after load");
+
+
+# test to see if luids are stable across record edit. (This was a bug on sqlite)
+
+$record2->set_props(props => { foo => 'bar'});
+
+$record2 = Prophet::Record->new(handle => $cxn, type => 'Empty');
+$record2->load(uuid => $uuid2);
+is($record2->uuid, $uuid2, "load accepts an luid");
+is($record2->luid, $luid2, "same luid after load");
+
+
+
+
+
+
+
+

commit de4b0bb7b8d1115671e28fc74117ade403959c82
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Fri Jan 16 08:58:38 2009 -0500

    sqlite replica type now does even less work when doing record updates.
    (This fixes the luid sequence bug I just checked in tests for)

diff --git a/lib/Prophet/Replica/sqlite.pm b/lib/Prophet/Replica/sqlite.pm
index d7624d6..f6a9473 100644
--- a/lib/Prophet/Replica/sqlite.pm
+++ b/lib/Prophet/Replica/sqlite.pm
@@ -225,7 +225,7 @@ for (
 
 q{
 CREATE TABLE records (
-    luid INTEGER PRIMARY KEY,
+    luid INTEGER PRIMARY KEY AUTOINCREMENT,
     uuid text,
     type text
 )
@@ -357,11 +357,13 @@ sub _write_record_to_db {
             if ( !defined $args{'props'}->{$_} || $args{'props'}->{$_} eq '' );
     }
 
-    # We're in a transaction here, right?
-    $self->_delete_record_from_db( uuid => $args{uuid} ) if
-        $self->record_exists( uuid => $args{uuid}, type => $args{type} );
-    $self->dbh->do( "INSERT INTO records (type, uuid) VALUES (?,?)", {},
+    if ($self->record_exists( uuid => $args{uuid}, type => $args{type} ) ) {
+        $self->_delete_record_props_from_db( uuid => $args{uuid} ) 
+    } else {
+        $self->dbh->do( "INSERT INTO records (type, uuid) VALUES (?,?)", {},
         $args{type}, $args{uuid} );
+
+    }
     $self->dbh->do(
         "INSERT INTO record_props (uuid, prop, value) VALUES (?,?,?)", {},
         $args{uuid}, $_, $args{props}->{$_} )
@@ -374,6 +376,13 @@ sub _delete_record_from_db {
     my %args = validate( @_, { uuid => 1 } );
 
     $self->dbh->do("DELETE FROM records where uuid = ?", {},$args{uuid});
+    $self->_delete_record_props_from_db(%args);
+}
+
+sub _delete_record_props_from_db {
+    my $self = shift;
+    my %args = validate( @_, { uuid => 1 } );
+
     $self->dbh->do("DELETE FROM record_props where uuid = ?", {}, $args{uuid});
 
 }

commit cf6f7b7ea8a4d2b76de5618a431921c5f9a5d8bb
Merge: de4b0bb... 65ab6b3...
Author: Jesse Vincent <jesse at bestpractical.com>
Date:   Fri Jan 16 08:59:20 2009 -0500

    Merge branch 'master' of code.bestpractical.com:/git/prophet


-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list