Skip to content

Commit 72e33d7

Browse files
author
Richard Jones
committed
Fix invalid date spec in db tests
Fix MySQL TEXT column usage
1 parent 095b603 commit 72e33d7

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

roundup/backends/back_mysql.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#$Id: back_mysql.py,v 1.61 2006-01-13 00:05:46 richard Exp $
1+
#$Id: back_mysql.py,v 1.62 2006-01-13 01:18:06 richard Exp $
22
#
33
# Copyright (c) 2003 Martynas Sklyzmantas, Andrey Lebedev <[email protected]>
44
#
@@ -379,6 +379,38 @@ def create_class_table(self, spec, create_sequence=1):
379379
self.create_class_table_indexes(spec)
380380
return cols, mls
381381

382+
def create_class_table_indexes(self, spec):
383+
''' create the class table for the given spec
384+
'''
385+
# create __retired__ index
386+
index_sql2 = 'create index _%s_retired_idx on _%s(__retired__)'%(
387+
spec.classname, spec.classname)
388+
self.sql(index_sql2)
389+
390+
# create index for key property
391+
if spec.key:
392+
if isinstance(spec.properties[spec.key], String):
393+
idx = spec.key + '(255)'
394+
else:
395+
idx = spec.key
396+
index_sql3 = 'create index _%s_%s_idx on _%s(_%s)'%(
397+
spec.classname, spec.key,
398+
spec.classname, idx)
399+
self.sql(index_sql3)
400+
401+
# TODO: create indexes on (selected?) Link property columns, as
402+
# they're more likely to be used for lookup
403+
404+
def create_class_table_key_index(self, cn, key):
405+
''' create the class table for the given spec
406+
'''
407+
prop = self.classes[cn].getprops()[key]
408+
if isinstance(prop, String):
409+
sql = 'create index _%s_%s_idx on _%s(_%s(255))'%(cn, key, cn, key)
410+
else:
411+
sql = 'create index _%s_%s_idx on _%s(_%s)'%(cn, key, cn, key)
412+
self.sql(sql)
413+
382414
def drop_class_table_indexes(self, cn, key):
383415
# drop the old table indexes first
384416
l = ['_%s_id_idx'%cn, '_%s_retired_idx'%cn]
@@ -492,6 +524,14 @@ def sql_commit(self):
492524
self.sql("SET AUTOCOMMIT=0")
493525
self.sql("START TRANSACTION")
494526

527+
def sql_close(self):
528+
logging.getLogger('hyperdb').info('close')
529+
try:
530+
self.conn.close()
531+
except MySQLdb.ProgrammingError, message:
532+
if str(message) != 'closing a closed connection':
533+
raise
534+
495535
class MysqlClass:
496536
# we're overriding this method for ONE missing bit of functionality.
497537
# look for "I can't believe it's not a toy RDBMS" below

test/db_test_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: db_test_base.py,v 1.61 2005-03-29 16:33:49 a1s Exp $
18+
# $Id: db_test_base.py,v 1.62 2006-01-13 01:18:07 richard Exp $
1919

2020
import unittest, os, shutil, errno, imp, sys, time, pprint
2121

@@ -262,7 +262,7 @@ def testDateChange(self):
262262
b = self.db.issue.get(nid, "deadline")
263263
if commit: self.db.commit()
264264
self.assertNotEqual(a, b)
265-
self.assertNotEqual(b, date.Date('1970-1-1 00:00:00'))
265+
self.assertNotEqual(b, date.Date('1970-1-1.00:00:00'))
266266

267267
def testDateUnset(self):
268268
for commit in (0,1):

0 commit comments

Comments
 (0)