clone_and_reset with relationships?

15 views
Skip to first unread message

James Masters

unread,
Jun 25, 2008, 10:03:10 AM6/25/08
to Rose::DB::Object
I've been using clone_and_reset which is dead handy but it would be
handier still if, when it ran, it also cloned any sub-table
relationship entries, as well as the main table record. I can
implement it by hand but it's just a suggestion to add to the todo
list, if it doesn't already exist in some form.

thanks.

John Siracusa

unread,
Jun 25, 2008, 10:16:04 AM6/25/08
to rose-db...@googlegroups.com

I'm actually working on a generic traversal helper right now. A
simple version of clone_and_reset_tree() (or whatever) might simply
Clone::PP the whole thing, then traverse the clone, calling
clone_and_reset() on each visited node.

-John

James Masters

unread,
Jun 26, 2008, 10:00:26 AM6/26/08
to Rose::DB::Object
> I'm actually working on a generic traversal helper right now.  

Sounds perfect; I shall look forward, thanks very much.

jon v

unread,
Jan 11, 2013, 3:58:19 PM1/11/13
to rose-db...@googlegroups.com


On Thursday, June 26, 2008 7:00:26 AM UTC-7, jfrm wrote:
> I'm actually working on a generic traversal helper right now.  

Sounds perfect; I shall look forward, thanks very much.

any progress on this?  i am also looking for a "deep clone", but i guess it really would be more of a deep clone_and_reset.  (e.g. i wish to duplicate the entire structure and the values within, but all using new primary keys.)

looks like i should probably just continue to roll my own at this point.  but just curious -- seems like clone_and_reset_tree() would be a handy thing to have!

thanks,
-jon 

John Siracusa

unread,
Jan 11, 2013, 4:12:51 PM1/11/13
to rose-db...@googlegroups.com
On Fri, Jan 11, 2013 at 3:58 PM, jon v <sito...@gmail.com> wrote:
> On Thursday, June 26, 2008 7:00:26 AM UTC-7, jfrm wrote:
>>
>> > I'm actually working on a generic traversal helper right now.
>>
>> Sounds perfect; I shall look forward, thanks very much.
>
> any progress on this?

http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Helpers.pm#traverse_depth_first_[_CODEREF_|_PARAMS_]

> i am also looking for a "deep clone", but i guess it
> really would be more of a deep clone_and_reset. (e.g. i wish to duplicate
> the entire structure and the values within, but all using new primary keys.)

Look at the as_* and new_from_* helper methods:

http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Helpers.pm

-John
Reply all
Reply to author
Forward
0 new messages