]> git.plutz.net Git - tabnote/commitdiff
Bugfix: dataloss because of wrong return value in setRecord, fixed!
authorpaul <paul@plutz.net>
Wed, 12 Jan 2011 01:43:18 +0000 (01:43 +0000)
committerpaul <paul@plutz.net>
Wed, 12 Jan 2011 01:43:18 +0000 (01:43 +0000)
svn path=/trunk/; revision=5

tabnote

diff --git a/tabnote b/tabnote
index 79295deab0a21e60c75a149ed5274ef3b2f6bfbd..897685814f6ef5c98eee948e99b53bbddf55c04d 100755 (executable)
--- a/tabnote
+++ b/tabnote
@@ -81,7 +81,7 @@ class Persistence():
     for c in string:
       if c == '"': ret += '""'
       else: ret += c
     for c in string:
       if c == '"': ret += '""'
       else: ret += c
-    return ret
+    return str(ret)
 
   def allRecords(self):
     """
 
   def allRecords(self):
     """
@@ -101,7 +101,7 @@ class Persistence():
       if content: content = self.escape(content)
       else: content = ''
       self.dbcur.execute('INSERT INTO notes (uuid, label, content, revision, lastsync) VALUES ' +
       if content: content = self.escape(content)
       else: content = ''
       self.dbcur.execute('INSERT INTO notes (uuid, label, content, revision, lastsync) VALUES ' +
-                        '(lower(hex(randomblob(16))), "' + label + '", "' + content +
+                        '(lower(hex(randomblob(16))), "' + str(label) + '", "' + str(content) +
                         '", datetime(\'now\'), datetime(\'1970-01-01\'));')
     else:    
       if content:
                         '", datetime(\'now\'), datetime(\'1970-01-01\'));')
     else:    
       if content:
@@ -111,7 +111,11 @@ class Persistence():
       if label:
         self.dbcur.execute('UPDATE notes SET label = "' + self.escape(label) +
                           '", revision = datetime(\'now\') WHERE uuid = "' + str(uuid) + '";')
       if label:
         self.dbcur.execute('UPDATE notes SET label = "' + self.escape(label) +
                           '", revision = datetime(\'now\') WHERE uuid = "' + str(uuid) + '";')
-    return self.dbcur.lastrowid
+
+    try:
+      self.dbcur.execute('SELECT uuid FROM notes WHERE seq = "' + str(self.dbcur.lastrowid) + '";')
+      return self.dbcur.fetchall()[0][0]
+    except: return 0
 
   def delRecord(self, uuid):
     """
 
   def delRecord(self, uuid):
     """