Skip to content

Commit 8a26f19

Browse files
author
Brian Kelley
committed
Many database-interface improvements.
1 Added an explicit close to the Indexer class. This was handled by garbage collection before. 2 Added an MKBackendError exception that gets thrown on some metakit errors. Should there be a general rdbms exception? 3 Added a sanity check when creating metakit tables in __getview There are some test cases that create columns of the same name with different metakit types. This can cause crashing issues with older version of metakit. We catch these before hand and raise an exception. 4 metakit db's cannot be weakref'd so this was removed 5 fixed a metakit.append, metakit must append lists, objects or dictionaries, it can't handle scalars. sv.append(int(entry)) became sv.append((int(entry),)) 6 To make it easier to compare to the other backends Class.keyname is changed to Class.key 7 Fixed Class.lookup, sometimes it would claim that a valid row was not valid (an _isdel row _property of 0 would be reported as 1) This is because metakit's view.find operation was returning bad results. This should be view.select or view.find on a single property. 8 calling create with no parameters raises a value error I'm not sure if this is appropriate, but it fixes a regression test :) 9 The get method was only converting results for commited values. uncommited values were not being converted using the metakit conversion table 10 Added a check to the Class.__init__ to raise a ValueError if the database already has a class of the same name. 11 Boolean and Number types can now have null values. This is a backwards incompatible fix in that old databases won't work correctly. The fix is simple. For a boolean column, 0 is now None 1 is False (returns 0) 2 is True (returns 1) For a numeric column, 0 is now None values 0 get returned as value-1 values < 0 get returned as value Set the BACKWARDS_COMPATIBLE flag to False to enable this fix. 12 Enumerated READ and READWRITE for the getview and getindexedview These will probably be removed because they are not used Known Current Bugs: It is currently is not possible to retire an id with name X and add a new unretired property with name X. Confused? Here is the regression test: self.assertRaises(ValueError, self.db.user.create) newid = self.db.user.create(username="spam") self.assertEqual(self.db.user.lookup('spam'), newid) self.db.commit() self.assertEqual(self.db.user.lookup('spam'), newid) self.db.user.retire(newid) self.assertRaises(KeyError, self.db.user.lookup, 'spam') # use the key again now that the old is retired (metakit FAILS!!) newid2 = self.db.user.create(username="spam") self.assertNotEqual(newid, newid2) # try to restore old node. this shouldn't succeed! self.assertRaises(KeyError, self.db.user.restore, newid) self.assertRaises(TypeError, self.db.issue.lookup, 'fubar') Boolean and number values will not return None (now fixed but breaks backwards compatibility) This causes some regression tests to fix, namely: def testPasswordUnset(self): x = password.Password('x') nid = self.db.user.create(username='foo', password=x) self.db.user.set(nid, assignable=None) self.assertEqual(self.db.user.get(nid, "assignable"), None)
1 parent 6747bf1 commit 8a26f19

File tree

1 file changed

+269
-59
lines changed

1 file changed

+269
-59
lines changed

0 commit comments

Comments
 (0)