Skip to content

Commit 6636609

Browse files
author
Richard Jones
committed
extend OTK and session table value cols to TEXT [SF#1031271]
1 parent 0fdc14f commit 6636609

File tree

5 files changed

+23
-9
lines changed

5 files changed

+23
-9
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Fixed:
4242
- handle Py2.3+ datetime objects as Date specs (sf bug 971300)
4343
- use row locking in MySQL newid() (sf bug 1034211)
4444
- add sanity check for sort and group on same property (sf bug 1033477)
45+
- extend OTK and session table value cols to TEXT (sf bug 1031271)
4546

4647

4748
2004-07-21 0.7.6

roundup/backends/back_mysql.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,14 @@ def open_connection(self):
170170
def create_version_2_tables(self):
171171
# OTK store
172172
self.sql('''CREATE TABLE otks (otk_key VARCHAR(255),
173-
otk_value VARCHAR(255), otk_time FLOAT(20))
173+
otk_value TEXT, otk_time FLOAT(20))
174174
TYPE=%s'''%self.mysql_backend)
175175
self.sql('CREATE INDEX otks_key_idx ON otks(otk_key)')
176176

177177
# Sessions store
178-
self.sql('''CREATE TABLE sessions (
179-
session_key VARCHAR(255), session_time FLOAT(20),
180-
session_value VARCHAR(255)) TYPE=%s'''%self.mysql_backend)
178+
self.sql('''CREATE TABLE sessions (session_key TEXT,
179+
session_time FLOAT(20), session_value VARCHAR(255))
180+
TYPE=%s'''%self.mysql_backend)
181181
self.sql('''CREATE INDEX sessions_key_idx ON
182182
sessions(session_key)''')
183183

roundup/backends/back_postgresql.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,13 @@ def open_connection(self):
113113
def create_version_2_tables(self):
114114
# OTK store
115115
self.sql('''CREATE TABLE otks (otk_key VARCHAR(255),
116-
otk_value VARCHAR(255), otk_time REAL)''')
116+
otk_value TEXT, otk_time REAL)''')
117117
self.sql('CREATE INDEX otks_key_idx ON otks(otk_key)')
118118

119119
# Sessions store
120120
self.sql('''CREATE TABLE sessions (
121121
session_key VARCHAR(255), session_time REAL,
122-
session_value VARCHAR(255))''')
122+
session_value TEXT)''')
123123
self.sql('''CREATE INDEX sessions_key_idx ON
124124
sessions(session_key)''')
125125

roundup/backends/back_sqlite.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: back_sqlite.py,v 1.32 2004-07-27 11:11:03 a1s Exp $
1+
# $Id: back_sqlite.py,v 1.33 2004-10-07 06:30:20 richard Exp $
22
'''Implements a backend for SQLite.
33
44
See https://pysqlite.sourceforge.net/ for pysqlite info
@@ -114,6 +114,10 @@ def add_new_columns_v2(self):
114114
# we've updated - don't try again
115115
tables[classname] = spec.schema()
116116

117+
def fix_version_3_tables(self):
118+
# NOOP - no restriction on column length here
119+
pass
120+
117121
def update_class(self, spec, old_spec, force=0, adding_v2=0):
118122
''' Determine the differences between the current spec and the
119123
database version of the spec, and update where necessary.

roundup/backends/rdbms_common.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.132 2004-10-07 06:08:42 richard Exp $
1+
# $Id: rdbms_common.py,v 1.133 2004-10-07 06:30:20 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -211,7 +211,7 @@ def post_init(self):
211211

212212
# update this number when we need to make changes to the SQL structure
213213
# of the backen database
214-
current_db_version = 3
214+
current_db_version = 4
215215
def upgrade_db(self):
216216
''' Update the SQL database to reflect changes in the backend code.
217217
@@ -241,9 +241,18 @@ def upgrade_db(self):
241241
self.config.logging.getLogger('hyperdb').info('upgrade to version 3')
242242
self.fix_version_2_tables()
243243

244+
if version < 4:
245+
self.fix_version_3_tables()
246+
244247
self.database_schema['version'] = self.current_db_version
245248
return 1
246249

250+
def fix_version_3_tables(self):
251+
# drop the shorter VARCHAR OTK column and add a new TEXT one
252+
for name in ('otk', 'session'):
253+
self.sql('ALTER TABLE %ss DROP %s_value'%(name, name))
254+
self.sql('ALTER TABLE %ss ADD %s_value TEXT'%(name, name))
255+
247256
def fix_version_2_tables(self):
248257
'''Default (used by sqlite): NOOP'''
249258
pass

0 commit comments

Comments
 (0)