Index: /branches/neb_distrib_20081210/Nebulous-Server/lib/Nebulous/Server.pm
===================================================================
--- /branches/neb_distrib_20081210/Nebulous-Server/lib/Nebulous/Server.pm	(revision 23759)
+++ /branches/neb_distrib_20081210/Nebulous-Server/lib/Nebulous/Server.pm	(revision 23760)
@@ -421,5 +421,5 @@
             my $query = $db->prepare_cached($sql->rename_object); 
             # this SQL statment takes the new key name as the first param
-            my $rows = $query->execute($newkey->path, basename($newkey->path), $key->path);
+            my $rows = $query->execute($newkey->path, basename($newkey->path), $self->_resolve_dir_parent_id($newkey), $key->path);
 
             # if we affected more then one row something very bad has happened.
@@ -497,5 +497,8 @@
               my $query = $db->prepare_cached($sql->rename_object); 
               # this SQL statment takes the new key name as the first param
-              my $rows = $query->execute($key1->path . ".swap", basename($key1->path) . ".swap", $key1->path);
+              # XXX currently using a bogus dir_id -- this may cause a problem
+              # someday but it's unlikley as it's contained entirely in the
+              # transaction
+              my $rows = $query->execute($key1->path . ".swap", basename($key1->path) . ".swap", 1, $key1->path);
 
               # if we affected more then one row something very bad has happened.
@@ -510,5 +513,5 @@
               my $query = $db->prepare_cached($sql->rename_object); 
               # this SQL statment takes the new key name as the first param
-              my $rows = $query->execute($key1->path, basename($key1->path), $key2->path);
+              my $rows = $query->execute($key1->path, basename($key1->path), $self->_resolve_dir_parent_id($key1), $key2->path);
 
               # if we affected more then one row something very bad has happened.
@@ -523,5 +526,5 @@
               my $query = $db->prepare_cached($sql->rename_object); 
               # this SQL statment takes the new key name as the first param
-              my $rows = $query->execute($key2->path, basename($key2->path), $key1->path . ".swap");
+              my $rows = $query->execute($key2->path, basename($key2->path), $self->_resolve_dir_parent_id($key2), $key1->path . ".swap");
 
               # if we affected more then one row something very bad has happened.
Index: /branches/neb_distrib_20081210/Nebulous-Server/lib/Nebulous/Server/SQL.pm
===================================================================
--- /branches/neb_distrib_20081210/Nebulous-Server/lib/Nebulous/Server/SQL.pm	(revision 23759)
+++ /branches/neb_distrib_20081210/Nebulous-Server/lib/Nebulous/Server/SQL.pm	(revision 23760)
@@ -316,5 +316,5 @@
     rename_object => qq{
         UPDATE storage_object
-        SET ext_id = ?, ext_id_basename = ?
+        SET ext_id = ?, ext_id_basename = ?, dir_id = ?
         WHERE ext_id = ?
     },
Index: /branches/neb_distrib_20081210/Nebulous-Server/t/03_server_create_object.t
===================================================================
--- /branches/neb_distrib_20081210/Nebulous-Server/t/03_server_create_object.t	(revision 23759)
+++ /branches/neb_distrib_20081210/Nebulous-Server/t/03_server_create_object.t	(revision 23760)
@@ -27,4 +27,6 @@
 );
 
+use Test::DBUnit dsn => $NEB_DB, username => $NEB_USER, password => $NEB_PASS;
+
 Test::Nebulous->setup;
 
@@ -336,5 +338,4 @@
 
 # test for properly row creation in the directories table
-use Test::DBUnit dsn => $NEB_DB, username => $NEB_USER, password => $NEB_PASS;
 
 Test::Nebulous->setup;
Index: /branches/neb_distrib_20081210/Nebulous-Server/t/13_server_rename_object.t
===================================================================
--- /branches/neb_distrib_20081210/Nebulous-Server/t/13_server_rename_object.t	(revision 23759)
+++ /branches/neb_distrib_20081210/Nebulous-Server/t/13_server_rename_object.t	(revision 23760)
@@ -8,8 +8,9 @@
 use warnings FATAL => qw( all );
 
-use Test::More tests => 7;
+use Test::More tests => 14;
 
 use lib qw( ./t ./lib );
 
+use File::Basename qw( basename );
 use Nebulous::Server;
 use Test::Nebulous;
@@ -21,10 +22,64 @@
 );
 
+use Test::DBUnit dsn => $NEB_DB, username => $NEB_USER, password => $NEB_PASS;
+
 Test::Nebulous->setup;
 
 {
+    my $key = "bar";
     my $uri = $neb->create_object("foo");
 
-    $neb->rename_object("foo", "bar");
+    $neb->rename_object("foo", $key);
+
+    expected_dataset_ok(
+        directory       => [dir_id => 1, dirname => '/', parent_id => 1],
+        storage_object  => [so_id => 1, ext_id => $key, ext_id_basename => basename($key), dir_id => 1],
+    );
+
+    eval {
+        $neb->find_objects('^foo$');
+    };
+    like($@, qr/no keys found/, "old key name");
+
+    my $keys = $neb->find_objects('^bar$');
+    is(scalar @$keys, 1, 'number of keys found');
+}
+
+Test::Nebulous->setup;
+
+{
+    my $key = "a/bar";
+    my $uri = $neb->create_object("foo");
+
+    $neb->rename_object("foo", $key);
+
+    expected_dataset_ok(
+        directory       => [dir_id => 1, dirname => '/', parent_id => 1],
+        directory       => [dir_id => 2, dirname => 'a', parent_id => 1],
+        storage_object  => [so_id => 1, ext_id => $key, ext_id_basename => basename($key), dir_id => 2],
+    );
+
+    eval {
+        $neb->find_objects('^foo$');
+    };
+    like($@, qr/no keys found/, "old key name");
+
+    my $keys = $neb->find_objects('^a/bar$');
+    is(scalar @$keys, 1, 'number of keys found');
+}
+
+Test::Nebulous->setup;
+
+{
+    my $key = "bar";
+    my $uri = $neb->create_object("a/foo");
+
+    $neb->rename_object("a/foo", $key);
+
+    expected_dataset_ok(
+        directory       => [dir_id => 1, dirname => '/', parent_id => 1],
+        directory       => [dir_id => 2, dirname => 'a', parent_id => 1],
+        storage_object  => [so_id => 1, ext_id => $key, ext_id_basename => basename($key), dir_id => 1],
+    );
 
     eval {
