evanmiller/boss_db — pull request #37 by kevinmontuori (2012-09-13 15:07:09+00:00)
Title: Adding UUID v4 type keys.

Hi Evan --

I have a use case where UUIDs and not serial integers are
required for the ID field throughout my DB. To facilitate this,
I've made a couple of changes to boss_db.git:

* passing Options to the boss_db_adapter_mock and then to
boss_db_mock_controller;

* setting the IdCounter (the second piece of state data) in the
mock_controller server to the atom "uuid" when the Option property
"db_keytype" is set to "uuid";

* generating a v4 UUID for unspecified Id fields;

* changing the way ExistingId is parsed (to bypass tokenization)
when the IdCounter state is set to "uuid".

Additionally, I've changed ChicagoBoss.git to add the property
"db_keytype" the Options sent to to boss_db:start/1. I'll submit a
pull request for that change and reference this one.

I've done preliminary testing with cb_admin and the scheme seems to be
working correctly for both {db_keytype, uuid} and an unspecified
db_keytype (i.e., it's backwards compatible). What I have not done
is:

* tested relationships between models;

* changed any of the external adapters (I have a need to update the
pgsql adapter which seems straightforward, I haven't examined the
others yet);

* updated the documentation appropriately.

Before I went any further, I wanted to float the idea by you to see if
it's something you'd consider adding to the mainline and to double
check that the methodology is sound. Any advice is welcome!

Note that I'm using Travis Vachon's erlang-uuid library (BSD licensed
and I believe redistributable in this way) to generate the UUIDs.

Thanks for your consideration and for a really useful framework.