Skip to content

Commit 912a3cf

Browse files
author
Richard Jones
committed
merge from HEAD
1 parent b806a54 commit 912a3cf

File tree

5 files changed

+30
-7
lines changed

5 files changed

+30
-7
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Fixed:
1313
- mailgw can override the MAIL_DEFAULT_CLASS
1414
- handle Py2.3+ datetime objects as Date specs (sf bug 971300)
1515
- use row locking in MySQL newid() (sf bug 1034211)
16+
- add sanity check for sort and group on same property (sf bug 1033477)
17+
- extend OTK and session table value cols to TEXT (sf bug 1031271)
1618

1719

1820
2004-07-21 0.7.6

roundup/backends/back_mysql.py

Lines changed: 6 additions & 2 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.cursor.execute('''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.cursor.execute('CREATE INDEX otks_key_idx ON otks(otk_key)')
176176

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

@@ -688,6 +688,10 @@ def filter(self, search_matches, filterspec, sort=(None,None),
688688
where.append('_%s.id in (%s)'%(cn, s))
689689
args = args + v
690690

691+
# sanity check: sorting *and* grouping on the same property?
692+
if group[1] == sort[1]:
693+
sort = (None, None)
694+
691695
# "grouping" is just the first-order sorting in the SQL fetch
692696
orderby = []
693697
ordercols = []

roundup/backends/back_postgresql.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ def open_connection(self):
122122
def create_version_2_tables(self):
123123
# OTK store
124124
self.cursor.execute('''CREATE TABLE otks (otk_key VARCHAR(255),
125-
otk_value VARCHAR(255), otk_time REAL)''')
125+
otk_value TEXT, otk_time REAL)''')
126126
self.cursor.execute('CREATE INDEX otks_key_idx ON otks(otk_key)')
127127

128128
# Sessions store
129129
self.cursor.execute('''CREATE TABLE sessions (
130130
session_key VARCHAR(255), session_time REAL,
131-
session_value VARCHAR(255))''')
131+
session_value TEXT)''')
132132
self.cursor.execute('''CREATE INDEX sessions_key_idx ON
133133
sessions(session_key)''')
134134

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.27.2.1 2004-05-10 00:15:59 richard Exp $
1+
# $Id: back_sqlite.py,v 1.27.2.2 2004-10-07 06:33:57 richard Exp $
22
'''Implements a backend for SQLite.
33
44
See https://pysqlite.sourceforge.net/ for pysqlite info
@@ -106,6 +106,10 @@ def add_new_columns_v2(self):
106106
# we've updated - don't try again
107107
tables[classname] = spec.schema()
108108

109+
def fix_version_3_tables(self):
110+
# NOOP - no restriction on column length here
111+
pass
112+
109113
def update_class(self, spec, old_spec, force=0, adding_v2=0):
110114
''' Determine the differences between the current spec and the
111115
database version of the spec, and update where necessary.

roundup/backends/rdbms_common.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.98.2.19 2004-07-20 23:27:02 richard Exp $
1+
# $Id: rdbms_common.py,v 1.98.2.20 2004-10-07 06:33:57 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -196,7 +196,7 @@ def post_init(self):
196196

197197
# update this number when we need to make changes to the SQL structure
198198
# of the backen database
199-
current_db_version = 3
199+
current_db_version = 4
200200
def upgrade_db(self):
201201
''' Update the SQL database to reflect changes in the backend code.
202202
@@ -222,9 +222,18 @@ def upgrade_db(self):
222222
if version < 3:
223223
self.fix_version_2_tables()
224224

225+
if version < 4:
226+
self.fix_version_3_tables()
227+
225228
self.database_schema['version'] = self.current_db_version
226229
return 1
227230

231+
def fix_version_3_tables(self):
232+
# drop the shorter VARCHAR OTK column and add a new TEXT one
233+
for name in ('otk', 'session'):
234+
self.sql('ALTER TABLE %ss DROP %s_value'%(name, name))
235+
self.sql('ALTER TABLE %ss ADD %s_value TEXT'%(name, name))
236+
228237
def fix_version_2_tables(self):
229238
'''Default (used by sqlite): NOOP'''
230239
pass
@@ -2211,6 +2220,10 @@ def filter(self, search_matches, filterspec, sort=(None,None),
22112220
where.append('_%s.id in (%s)'%(cn, s))
22122221
args = args + v
22132222

2223+
# sanity check: sorting *and* grouping on the same property?
2224+
if group[1] == sort[1]:
2225+
sort = (None, None)
2226+
22142227
# "grouping" is just the first-order sorting in the SQL fetch
22152228
orderby = []
22162229
ordercols = []

0 commit comments

Comments
 (0)