On Thu, Sep 4, 2008 at 11:58 AM, Paul Johnston <[EMAIL PROTECTED]> wrote: > > I have a need to clone persistent objects. I'd like to take an > existing object, copy everything except the primary key, so it gets a > new key when flushed to the database. As a slight twist, I want this > to be a deep copy - copying related objects as well. > > I don't think Elixir has much support for this (correct me if I'm > wrong). I have some fairly hacky code to do this; if there's interest, > I'd be happy to tidy it up and produce a patch. > > Good idea?
Adding a copy() method on the entity is IMO a good idea. And having it possibly deep-copy is a nice bonus. I guess your deep-copy feature is done by specifying the fields you want copied "deeply", in a similar fashion to what is done in to_dict. Here is a couple remarks before you go for it: - it'd be nice to use the same way to define "deep" fields as in to_dict - pay attention to the properties names, which, even for a "column property" can be different from the column name. See to_dict method for a (mostly correct -- except the FIXME in there) example. See you, -- Gaƫtan de Menten http://openhex.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "SQLElixir" 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/sqlelixir?hl=en -~----------~----~----~----~------~----~------~--~---
