Mercurial > p > roundup > code
changeset 2457:3fe516581aa3 maint-0.7
merge from HEAD
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Mon, 14 Jun 2004 03:39:34 +0000 |
| parents | 32c813e7f03f |
| children | debf57fc8c0f |
| files | CHANGES.txt roundup/backends/back_mysql.py |
| diffstat | 2 files changed, 29 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGES.txt Sun Jun 13 01:11:23 2004 +0000 +++ b/CHANGES.txt Mon Jun 14 03:39:34 2004 +0000 @@ -7,6 +7,7 @@ - fixed lookup of "missing" Link values for new props in anydbm backend - allow list of values for id, Number and Boolean filtering in anydbm backend +- fixed some more mysql 0.6->0.7 upgrade bugs (sf bug 950410) 2004-06-10 0.7.4
--- a/roundup/backends/back_mysql.py Sun Jun 13 01:11:23 2004 +0000 +++ b/roundup/backends/back_mysql.py Mon Jun 14 03:39:34 2004 +0000 @@ -140,8 +140,8 @@ except MySQLdb.OperationalError, message: raise DatabaseError, message cursor = conn.cursor() - cursor.execute("SET AUTOCOMMIT=0") - cursor.execute("BEGIN") + cursor.execute("SET AUTOCOMMIT=OFF") + cursor.execute("START TRANSACTION") return (conn, cursor) def open_connection(self): @@ -251,6 +251,8 @@ # unserialise the old data olddata = [] propnames = propnames + ['id', '__retired__'] + cols = [] + first = True for entry in self.cursor.fetchall(): l = [] olddata.append(l) @@ -259,8 +261,12 @@ v = entry[i] if name in ('id', '__retired__'): + if first: + cols.append(name) l.append(int(v)) continue + if first: + cols.append('_' + name) prop = properties[name] if isinstance(prop, Date) and v is not None: v = date.Date(v) @@ -280,10 +286,13 @@ # Intervals store the seconds value too if isinstance(prop, Interval): + if first: + cols.append('__' + name + '_int__') if v is not None: l.append(v.as_seconds()) else: l.append(e) + first = False self.drop_class_table_indexes(cn, old_spec[0]) @@ -294,8 +303,9 @@ self.create_class_table(klass) # do the insert of the old data - args = ','.join([self.arg for x in fetch]) - sql = 'insert into _%s (%s) values (%s)'%(cn, fetchcols, args) + args = ','.join([self.arg for x in cols]) + cols = ','.join(cols) + sql = 'insert into _%s (%s) values (%s)'%(cn, cols, args) if __debug__: print >>hyperdb.DEBUG, 'migration', (self, sql) for entry in olddata: @@ -491,6 +501,20 @@ print >>hyperdb.DEBUG, 'create_class', (self, sql, vals) self.cursor.execute(sql, vals) + def sql_commit(self): + ''' Actually commit to the database. + ''' + if __debug__: + print >>hyperdb.DEBUG, '+++ commit database connection +++' + self.conn.commit() + + # open a new cursor for subsequent work + self.cursor = self.conn.cursor() + + # make sure we're in a new transaction and not autocommitting + self.cursor.execute("SET AUTOCOMMIT=OFF") + self.cursor.execute("START TRANSACTION") + class MysqlClass: # we're overriding this method for ONE missing bit of functionality. # look for "I can't believe it's not a toy RDBMS" below
