Merge lp:~jameinel/u1db/uuid_databases into lp:u1db
Status: | Merged |
---|---|
Merged at revision: | 135 |
Proposed branch: | lp:~jameinel/u1db/uuid_databases |
Merge into: | lp:u1db |
Diff against target: |
183 lines (+68/-11) (has conflicts) 4 files modified
u1db/backends/sqlite_backend.py (+19/-5) u1db/commandline/client.py (+7/-1) u1db/tests/commandline/test_client.py (+17/-2) u1db/tests/test_sqlite_backend.py (+25/-3) Text conflict in u1db/commandline/client.py |
To merge this branch: | bzr merge lp:~jameinel/u1db/uuid_databases |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Samuele Pedroni | Approve | ||
Review via email: mp+83945@code.launchpad.net |
Description of the change
This changes SQLiteDatabase so that it defaults to creating a unique replica_uid when it initializes the database.
Some comments:
1) We never set a uniqueness constraint on the u1db_config table, so we could call _set_replica_uid as much as we wanted, but it wouldn't actually change it, since it just added more data to the db.
2) I went with: uuid.uuid4().hex. Which is 32 bytes long (vs the default 36 bytes with the extra '-' chars).
This should make it reasonably short, since it will end up in all the doc revs, etc.
We've talked about including something like hostname, to help in debugging issues. For now, this was simple and works, we can extend it later, I think.
3) We use 'index_storage' as a flag to indicate the db has been set up, move it to after _extra_schema_init and _set_replica_uid.
from my understarding while with sqlite3
with conn:
A
with conn:
B
C
is permitted, it doesn't do what one would expect, it will result in a commit after B and one after C (or more depending on the isolation level)
this means _initialize shouldn't call a helper with a with conn: of its own (_set_replica_uid), so things need to be factored a bit differently