[Nitro] Og UUIDs

Jonathan Buch john at oxyliquit.de
Mon Apr 23 08:48:09 EDT 2007


(This post is mostly for George and Lester)

I've now upgraded Og (well, the last 25 outstanding patches) where Og
is now UUID enabled.

Now some questions.

The new hook `:create_primary_key`, This behaves like `last_insert_id`
for PostgreSQL used to behave.
Unfortunately the new behaviour of that area isn't as 'obvious' as it
used to be (to me).  Could this create_primary_key be expanded to
be the normal case?  It would execute nextval(), save the key and then
go on to:

## sql.rb
def og_insert
# THINK: investigate why this is needed.
pk_new = store.insert(self.class, inserts)
pk = pk_new unless pk

George, I think this is merely the 'standard case'.  When create_p_k
was not executed, the .pk will always be empty and thus needs to be
replaced by the oid of the actual INSERT.

I'm just not sure where to put this  `create_primary_key` so it only
gets included into the model when the specific model is backed by
psql.  Where would that go to?  (also so that it also can get easily
be replaced by a custom create_p_k like UUID does.)

Next question:

Why create a special module for UUIDs?  (except the reason that
create_p_k has to be available).  The first thing that came to my
mind on how to use UUIDs:

class MyModel
   attr_accessor :oid, UUID, :primary_key => true

And Og handling the rest via the typemap.
Together with a `autoload :UUID, 'uuidtools'` somewhere in Og...

Ah, and I absolutely hate the to 22 encoder, it doesn't preserve
the orderability of the time-uuids.  ;/  But I guess that's the
price you pay for not using more bytes..


Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

More information about the Nitro-general mailing list