changeset 3308:c7c25f2103b2 maint-0.7 0.7.12

fix RDBMS clear() so it resets all class itemid counters
author Richard Jones <richard@users.sourceforge.net>
date Mon, 02 May 2005 05:44:56 +0000
parents 5392c7e182b3
children 8833a5919a37
files roundup/backends/back_mysql.py roundup/backends/back_postgresql.py roundup/backends/back_sqlite.py roundup/backends/rdbms_common.py
diffstat 4 files changed, 10 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/roundup/backends/back_mysql.py	Mon May 02 05:12:23 2005 +0000
+++ b/roundup/backends/back_mysql.py	Mon May 02 05:44:56 2005 +0000
@@ -497,11 +497,6 @@
         self.cursor.execute(sql, vals)
 
     def clear(self):
-        '''Delete all database contents.
-
-        Note: I don't commit here, which is different behaviour to the
-              "nuke from orbit" behaviour in the dbs.
-        '''
         rdbms_common.Database.clear(self)
 
         # set the id counters to 0 (setid adds one) so we start at 1
--- a/roundup/backends/back_postgresql.py	Mon May 02 05:12:23 2005 +0000
+++ b/roundup/backends/back_postgresql.py	Mon May 02 05:44:56 2005 +0000
@@ -219,9 +219,16 @@
         sql = "select setval('_%s_ids', %s) from dual"%(classname, int(setid))
         if __debug__:
             print >>hyperdb.DEBUG, 'setid', (self, sql)
-        print 'setid', (self, sql)
         self.cursor.execute(sql)
 
+    def clear(self):
+        rdbms_common.Database.clear(self)
+
+        # reset the sequences
+        for cn in self.classes.keys():
+            self.cursor.execute('DROP SEQUENCE _%s_ids'%cn)
+            self.cursor.execute('CREATE SEQUENCE _%s_ids'%cn)
+
 
 class Class(rdbms_common.Class):
     pass
--- a/roundup/backends/back_sqlite.py	Mon May 02 05:12:23 2005 +0000
+++ b/roundup/backends/back_sqlite.py	Mon May 02 05:44:56 2005 +0000
@@ -1,4 +1,4 @@
-# $Id: back_sqlite.py,v 1.27.2.4 2005-05-02 01:03:40 richard Exp $
+# $Id: back_sqlite.py,v 1.27.2.5 2005-05-02 05:44:56 richard Exp $
 '''Implements a backend for SQLite.
 
 See https://pysqlite.sourceforge.net/ for pysqlite info
@@ -329,11 +329,6 @@
         self.cursor.execute(sql, vals)
 
     def clear(self):
-        '''Delete all database contents.
-
-        Note: I don't commit here, which is different behaviour to the
-              "nuke from orbit" behaviour in the dbs.
-        '''
         rdbms_common.Database.clear(self)
 
         # set the id counters to 0 (setid adds one) so we start at 1
--- a/roundup/backends/rdbms_common.py	Mon May 02 05:12:23 2005 +0000
+++ b/roundup/backends/rdbms_common.py	Mon May 02 05:44:56 2005 +0000
@@ -1,4 +1,4 @@
-# $Id: rdbms_common.py,v 1.98.2.31 2005-05-02 01:03:40 richard Exp $
+# $Id: rdbms_common.py,v 1.98.2.32 2005-05-02 05:44:56 richard Exp $
 ''' Relational database (SQL) backend common code.
 
 Basics:
@@ -694,7 +694,6 @@
             if __debug__:
                 print >>hyperdb.DEBUG, 'clear', (self, sql)
             self.cursor.execute(sql)
-            self.setid(cn, 1)
 
     #
     # Nodes

Roundup Issue Tracker: http://roundup-tracker.org/