Skip to content

Commit 1b8ea73

Browse files
author
Richard Jones
committed
fixes for [SF#818339]
fixes for metakit for the new db unit tests
1 parent 0cd8e5c commit 1b8ea73

File tree

6 files changed

+47
-17
lines changed

6 files changed

+47
-17
lines changed

doc/installation.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Installing Roundup
33
==================
44

5-
:Version: $Revision: 1.63 $
5+
:Version: $Revision: 1.64 $
66

77
.. contents::
88

@@ -242,8 +242,12 @@ There's several to choose from, each with benefits and limitations:
242242
**mysql**
243243
Backend for popular RDBMS MySQL. According to benchmarks, this backend works
244244
much faster than any of \*dbm ones, but slightly slower than metakit and
245-
sqlite. A good scalability is not a property of this backend for now,
246-
though. For more info on backend installation see doc/mysql.txt.
245+
sqlite. For more info on backend installation see doc/mysql.txt.
246+
**postgresql**
247+
Backend for popular RDBMS PostgreSQL. According to benchmarks, this
248+
backend works much faster than any of \*dbm ones and mysql, but slightly
249+
slower than metakit and sqlite.
250+
For more info on backend installation see doc/postgresql.txt.
247251
**metakit**
248252
This backend is implemented over the metakit_ storage system, using Mk4Py as
249253
the interface. It scales much better than the dbm backends.

doc/mysql.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
MySQL Backend
33
=============
44

5-
:version: $Revision: 1.5 $
5+
:version: $Revision: 1.6 $
66

77
This notes detail the MySQL backend for the Roundup issue tracker.
88

@@ -18,6 +18,8 @@ to install:
1818
if you have no other choice)
1919
2. Python MySQL interface - http://sourceforge.net/projects/mysql-python
2020

21+
:Note: the InnoDB implementation has a bug that Roundup tickles. See
22+
http://bugs.mysql.com/bug.php?id=1810
2123

2224
Running the MySQL tests
2325
=======================

roundup/backends/back_metakit.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: back_metakit.py,v 1.51 2003-10-07 11:58:57 anthonybaxter Exp $
1+
# $Id: back_metakit.py,v 1.52 2003-11-12 03:42:12 richard Exp $
22
'''
33
Metakit backend for Roundup, originally by Gordon McMillan.
44
@@ -140,7 +140,7 @@ def addjournal(self, tablenm, nodeid, action, params, creator=None,
140140
if tblid == -1:
141141
tblid = self.tables.append(name=tablenm)
142142
if creator is None:
143-
creator = self.getuid()
143+
creator = int(self.getuid())
144144
else:
145145
try:
146146
creator = int(creator)
@@ -628,7 +628,7 @@ def set(self, nodeid, **propvalues):
628628
if not row.creation:
629629
row.creation = int(time.time())
630630
if not row.creator:
631-
row.creator = self.db.getuid()
631+
row.creator = int(self.db.getuid())
632632

633633
self.db.dirty = 1
634634
if self.do_journal:
@@ -734,6 +734,11 @@ def setkey(self, propname):
734734
if not isinstance(prop, hyperdb.String):
735735
raise TypeError, "%s is not a String" % propname
736736

737+
# TODO: metakit needs to be able to cope with the key property
738+
# *changing*, which it can't do at present. At the moment, it
739+
# creates the key prop index once, with no record of the name of
740+
# the property for the index.
741+
737742
# first setkey for this run
738743
self.keyname = propname
739744
iv = self.db._db.view('_%s' % self.classname)
@@ -814,7 +819,10 @@ def find(self, **propspec):
814819
else:
815820
d = {}
816821
for id in ids.keys():
817-
d[int(id)] = 1
822+
if id is None:
823+
d[0] = 1
824+
else:
825+
d[int(id)] = 1
818826
ids = d
819827
prop = self.ruprops[propname]
820828
view = self.getview()

roundup/backends/back_mysql.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,12 @@ def db_exists(config):
4949
class Database(Database):
5050
arg = '%s'
5151

52-
# backend for MySQL to use
53-
mysql_backend = 'InnoDB'
54-
#mysql_backend = 'BDB' # much slower, only use if you have no choice
52+
# Backend for MySQL to use.
53+
# InnoDB is faster, but has a bug in its rollback machinery that causes
54+
# some selects in subsequent transactions to fail. BDB does not have
55+
# this bug, but is apparently much slower.
56+
#mysql_backend = 'InnoDB'
57+
mysql_backend = 'BDB'
5558

5659
def sql_open_connection(self):
5760
db = getattr(self.config, 'MYSQL_DATABASE')

roundup/backends/rdbms_common.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.68 2003-11-12 01:00:58 richard Exp $
1+
# $Id: rdbms_common.py,v 1.69 2003-11-12 03:42:12 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -1783,8 +1783,8 @@ def find(self, **propspec):
17831783
'propspec' consists of keyword args propname=nodeid or
17841784
propname={nodeid:1, }
17851785
'propname' must be the name of a property in this class, or a
1786-
KeyError is raised. That property must be a Link or Multilink
1787-
property, or a TypeError is raised.
1786+
KeyError is raised. That property must be a Link or
1787+
Multilink property, or a TypeError is raised.
17881788
17891789
Any node in this class whose 'propname' property links to any of the
17901790
nodeids will be returned. Used by the full text indexing, which knows
@@ -1816,6 +1816,8 @@ def find(self, **propspec):
18161816
for prop, values in propspec:
18171817
if not isinstance(props[prop], hyperdb.Link):
18181818
continue
1819+
if type(values) is type({}) and len(values) == 1:
1820+
values = values.keys()[0]
18191821
if type(values) is type(''):
18201822
allvalues += (values,)
18211823
where.append('_%s = %s'%(prop, a))

test/db_test_base.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
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.6 2003-11-11 11:19:18 richard Exp $
18+
# $Id: db_test_base.py,v 1.7 2003-11-12 03:42:13 richard Exp $
1919

20-
import unittest, os, shutil, errno, imp, sys, time
20+
import unittest, os, shutil, errno, imp, sys, time, pprint
2121

2222
from roundup.hyperdb import String, Password, Link, Multilink, Date, \
2323
Interval, DatabaseError, Boolean, Number, Node
@@ -615,24 +615,35 @@ def testFind(self):
615615
got = self.db.issue.find(status='1')
616616
got.sort()
617617
self.assertEqual(got, ids)
618+
got = self.db.issue.find(status={'1':1})
619+
got.sort()
620+
self.assertEqual(got, ids)
618621

619622
# none
620623
self.assertEqual(self.db.issue.find(status='4'), [])
624+
self.assertEqual(self.db.issue.find(status={'4':1}), [])
621625

622626
# should match first and third
623627
got = self.db.issue.find(assignedto=None)
624628
got.sort()
625629
self.assertEqual(got, ids)
630+
got = self.db.issue.find(assignedto={None:1})
631+
got.sort()
632+
self.assertEqual(got, ids)
626633

627634
# should match first three
628635
got = self.db.issue.find(status='1', nosy='2')
629636
got.sort()
630637
ids.append(oddid)
631638
ids.sort()
632639
self.assertEqual(got, ids)
640+
got = self.db.issue.find(status={'1':1}, nosy={'2':1})
641+
got.sort()
642+
self.assertEqual(got, ids)
633643

634644
# none
635645
self.assertEqual(self.db.issue.find(status='4', nosy='3'), [])
646+
self.assertEqual(self.db.issue.find(status={'4':1}, nosy={'3':1}), [])
636647

637648
def testStringFind(self):
638649
ids = []
@@ -852,7 +863,7 @@ def test_changeClassKey(self):
852863
self.assertEqual(self.db.a.lookup('apple'), aid)
853864
self.db.commit(); self.db.close()
854865

855-
# change the key to fooz
866+
# change the key to fooz on a
856867
self.init_amodkey()
857868
self.assertEqual(self.db.a.get(aid, 'name'), 'apple')
858869
self.assertEqual(self.db.a.get(aid, 'fooz'), None)

0 commit comments

Comments
 (0)