summaryrefslogtreecommitdiffstats
path: root/Lib/bsddb
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2007-11-05 02:32:26 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2007-11-05 02:32:26 (GMT)
commitec10a4a402e5b6845b247f688fc157be45414cdd (patch)
tree99112af225bd76faa84bad94a826406bf77c7065 /Lib/bsddb
parent9c466baa014fa32474f338cc153caea8236a0555 (diff)
downloadcpython-ec10a4a402e5b6845b247f688fc157be45414cdd.zip
cpython-ec10a4a402e5b6845b247f688fc157be45414cdd.tar.gz
cpython-ec10a4a402e5b6845b247f688fc157be45414cdd.tar.bz2
Fixes bug 477182 on pybsddb.sf.net. DB objects now load the flags and
pay attention to them when opening an existing database. This means that d[] behaves properly even on databases previously created with DB_DUP or DB_DUPSORT flags to allow duplicate keys. http://sourceforge.net/tracker/index.php?func=detail&aid=477182&group_id=13900&atid=113900 Do not backport, this bugfix could be considered an API change.
Diffstat (limited to 'Lib/bsddb')
-rw-r--r--Lib/bsddb/test/test_misc.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/bsddb/test/test_misc.py b/Lib/bsddb/test/test_misc.py
index 1212581..598e626 100644
--- a/Lib/bsddb/test/test_misc.py
+++ b/Lib/bsddb/test/test_misc.py
@@ -90,6 +90,30 @@ class MiscTestCase(unittest.TestCase):
db1.close()
os.unlink(self.filename)
+ def test_DB_set_flags_persists(self):
+ try:
+ db1 = db.DB()
+ db1.set_flags(db.DB_DUPSORT)
+ db1.open(self.filename, db.DB_HASH, db.DB_CREATE)
+ db1['a'] = 'eh'
+ db1['a'] = 'A'
+ self.assertEqual([('a', 'A')], db1.items())
+ db1.put('a', 'Aa')
+ self.assertEqual([('a', 'A'), ('a', 'Aa')], db1.items())
+ db1.close()
+ db1 = db.DB()
+ # no set_flags call, we're testing that it reads and obeys
+ # the flags on open.
+ db1.open(self.filename, db.DB_HASH)
+ self.assertEqual([('a', 'A'), ('a', 'Aa')], db1.items())
+ # if it read the flags right this will replace all values
+ # for key 'a' instead of adding a new one. (as a dict should)
+ db1['a'] = 'new A'
+ self.assertEqual([('a', 'new A')], db1.items())
+ finally:
+ db1.close()
+ os.unlink(self.filename)
+
#----------------------------------------------------------------------