Issue #3 resolved

Consecutive Database.create() calls can render a database unopenable

Jesse Dhillon
created an issue

Currently, if you run Database.create() twice on the same database, the second call will create entries in _indexes/ which correspond to another id index. However, while the call will fail, those entries will remain.

If you correct your code to correctly call Database.open(), open will still throw IndexConflict('Already exists'). The only way to remedy this is to figure out which file in _indexes/ to remove.

The correct behavior, in my opinion, is that Database.create() should not leave the database in an unopenable state.

Comments (3)

  1. Jesse Dhillon reporter

    Incidentally, this was discovered as I fumbled my way through the tutorials and discovered this idiom:

    db = Database('/foo/bar')
    
    if db.exists():
        db.open()
    
    else:
        db.create()
    

    This is apparently the correct way to handle the two cases of db.exists() and not db.exists() in a single branch. Perhaps it should be documented.

  2. Log in to comment