I've already solved this in my app.  We are using DM with a legacy
schema (still in use by another app, so cannot be modified too much)
and all of the PK's are generated from a sequences table (it's just
`name` and `id` columns).

I've just done this with a "before :create" hook in my models, and the
logic is just:

SELECT id FROM sequences WHERE name = sequence_name FOR UPDATE
UPDATE sequences SET id = id + 1 WHERE name = sequence_name

I can't help but feel I've reinvented the wheel given that this is
such a common design pattern, so does anyone know of a plugin that
handles Serial fields via a sequences table?

Cheers,

Chris

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to