=== Open Bugs ===
 
 * Add form shown although not logged in
-* Tag Rename case sensitiv
 * Case-sensitivity in SELECT statements with Postgres really do a number on
   the tag algorithms
 * Tag operations (op=tags) or not working yet.
 
 06.2011 CEST jumpin.banana
        * tag suggest was not working correctly.
        * tag rename feature implemented
+       * tag rename case sensitiv problem
        
 Tue Jul 14 21:38 EST 2009  Luke Reeve   <luke@neuro-tech.net>
 
 
                my $newTag = param('newName');
                my $oldTagName = param('rename');
                my $oldTagId = get_tag_id_by_name($oldTagName);
+               print Dumper "oldtagid: ".$oldTagId;
                
                # is the new name already a tag ?
                # if check then check is the new tagId
                my $check = get_tag_id_by_name($newTag);
-               if($check) {
+               print Dumper "newtagid: ".$check;
+               if($check && ($check != $oldTagId)) {
                        my $sql = "SELECT bookmark_id, tag_id 
                                                FROM `$tbl_bookmark_tags`
                                                WHERE tag_id = ?";
                        my $sth = $dbh->prepare($sql);
                        $sth->execute($oldTagId);
                        while(my ($bid, $tid) = $sth->fetchrow_array) {
-                               #print Dumper $bid;
                                my $sql1 = "DELETE FROM `$tbl_bookmark_tags` 
                                                        WHERE bookmark_id = ?
                                                        AND tag_id = ?";
                }
                else {
                        # just rename the tag
-                       my $sql = "UPDATE $tbl_tags SET name = ? WHERE name = ?";
+                       my $sql = "UPDATE $tbl_tags SET name = ? WHERE id = ?";
                        my $sth = $dbh->prepare($sql);
-                       $sth->execute($oldTagId);
+                       $sth->execute($newTag,$oldTagId);
                }
                
                print '<span style="color: green;">Done !</span>';
 
            # or create a new tag
            if ($tagcount < 1) {
-               my $sql = "insert into $tbl_tags (name) values(?)";
-               my $sth = $dbh->prepare($sql);
-               $sth->execute($cur);
+                       my $sql = "insert into $tbl_tags (name) values(?)";
+                       my $sth = $dbh->prepare($sql);
+                       $sth->execute($cur);
            }
 
            # and fetch the tag ID