[Dbix-class] Automatically "create" on related tables

Jess Robinson castaway at desert-island.me.uk
Thu Apr 26 21:58:44 GMT 2007




On Tue, 24 Apr 2007, Eduard Gim=E9nez wrote:

> Hi,
>
> I'm working on a existing DB which has some data spanned across several
> tables. For example each user has an entry on the table "users" and on the
> "user_data" table. I know that it's not he best option, but It's how the =
DB
> is and I can change it :(
>
> Currently to add a new user I do (on Catalyst, btw):
>
> $u =3D $c->model('myDB::users')->create( { email =3D> $email, active =3D>=
 1,
> ...});
> $u->create_related('user_data', {field01 =3D> $field1, field02 =3D> $fiel=
d02,
> ...});
>
> I would like to do something similar what is shown at [1]
>
> $c->model('myDB::users')->create( { email =3D> $email,
> 						active =3D> 1,
> 						...
> 						user_data =3D> {field01 =3D>
> $field1,
> 								  field02 =3D>
> $field02,
> 								  ...},
> 					   } );
>
>> From that [2] Matt's message I undersant that this feature was going to =
be
> merged. Is that true? Has been already merged? On which DBIx::Class versi=
on?
>
> TIA,
>
> [1] http://www.mail-archive.com/dbix-class@lists.rawmode.org/msg02624.htm=
l:
> [2] http://www.mail-archive.com/dbix-class@lists.rawmode.org/msg02671.html
>

No, it hasn't.. it's lurking in the bulk_create branch, looking for more =

tuits, and some nice people to write more scary tests to stress it.

What you've shown does work.. its find_or_create type stuff that doesnt =

yet.

Jess


More information about the Dbix-class mailing list