Database.ensure() should return True if the database was created, False if it already existed
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Microfiber |
Fix Released
|
High
|
Akshat Jain |
Bug Description
Database.ensure() tries to create the database, and handles the PreconditionFailed exception for you if the database already exists:
http://
(URL updated by Manish. Please use specific commit URL instead of HEAD since the line number for a method can change in HEAD).
However, it would be handy to know whether the database was created, so you know if say there is some initialization work you must do. Like this:
db = Database('novacut')
if db.ensure():
# Must be first time running Novacut, lets initialize and so forth
pass
This way Database.ensure() will match the semantics of the filestore.
http://
(URL updated by Manish. Please use specific commit URL instead of HEAD since the line number for a method can change in HEAD).
This is a tiny change, and then you'll just have to update the Live unit test for Database.
http://
The "live" tests aren't run by default, as they require CouchDB to be available. Run the live tests against system-wide CouchDB like this:
./setup.py test --live
Or run them against desktopcouch like this:
./setup.py --dc
But you need to have dmedia installed for the --dc option to work.
Related branches
- Jason Gerard DeRose: Approve
-
Diff: 30 lines (+5/-3)2 files modifiedmicrofiber.py (+3/-1)
test_microfiber.py (+2/-2)
description: | updated |
Changed in microfiber: | |
status: | Triaged → In Progress |
summary: |
- Database.ensure() should return True if the database was created, Fales + Database.ensure() should return True if the database was created, False if it already existed |
description: | updated |
Changed in microfiber: | |
status: | In Progress → Fix Committed |
Changed in microfiber: | |
status: | Fix Committed → Fix Released |