Object Id update

1 view
Skip to first unread message

gaddoz

unread,
Jan 28, 2009, 4:52:30 AM1/28/09
to jazzrecord
Hi all

I'm trying to change the Id of a persisted object, but I get exception
when I try to save,
because JazzRecord try to update the object with the new Id, that it
doesn't exist on the db.

There is any way to achieve that?

Thanks in advance!

Nick Carter

unread,
Jan 28, 2009, 6:04:51 PM1/28/09
to jazzrecord
First, thanks for posting on the group. Every input is valuable to me.

There's currently no facility for doing this, no. IDs are currently
treated separately from the other columns in the table. I can add it
in the next release (0.7), which will also include full manual
migrations support. I'd also like to eventually allow alternate names
than "id", and may find time to work that in as well. The next release
will be within a week.

As a workaround for the time being, you can adjust any references to
this record's ID on foreign records.

For example, if your record is a person, update the "person_id" on the
foreign records so it matches. You can accomplish this manually or by
reassigning the association and saving:

//example one
foreignObj.person_id = person.id;
foreignObj.save();

//example two
foreignObj.person = person;
foreignObj.save();

Nick Carter

unread,
Jan 29, 2009, 11:11:42 AM1/29/09
to jazzrecord
I added the ability to change the id property last night. It will
definitely be in the next release, which may be this weekend.
Streamlined migrations, a newly-added isNew() function on Record
objects, and updated/expanded tests round out the release.

On Jan 28, 4:52 am, gaddoz <gad...@gmail.com> wrote:

gaddoz

unread,
Jan 30, 2009, 5:25:41 AM1/30/09
to jazzrecord
Great news !!

Nick Carter

unread,
Feb 8, 2009, 2:43:31 AM2/8/09
to jazzrecord
This is now possible in 0.7, which you should fetch from Github!
Reply all
Reply to author
Forward
0 new messages