OK, I have changed my code a bit, so that it now has

            $obj = $c->model( q{MyAppDB::MyTable})->create( {} );
       $obj->populate_from_widget($result);

In other words, I have replaced the 'new' in the first line by a 'create'.
The result (as verified by the DBIC trace) is an insert with no columns
specified, followed by an update of all the fields.

This does work (the primary key in the model is set properly, and
$obj->mytable_id returns the new key). As it happens, insertion efficiency
is not crucial to my current application, so I can go with the workaround.

But it does look like a bug to me.


On 10/12/2007, Martin Ellison <[EMAIL PROTECTED]> wrote:
>
> My table class is basically:
>
> use base qw/DBIx::Class/;
>
> __PACKAGE__->load_components(qw/PK::Auto Core HTMLWidget/);
>
> # Set the table name
> __PACKAGE__->table('mytable');
>
> # Set columns in table
> __PACKAGE__->add_columns(
>     qw/mytable_id title date/
> );
>
> # Set the primary key for the table
> __PACKAGE__->set_primary_key(q/mytable_id/);
>
> That should cover off Paul's concerns.
>
> It seems that set_primary_key can take either a single string or a
> reference to an array of strings, but neither work for me. (Or rather, they
> work for update but not insert).
>
> On 10/12/2007, kevin montuori <[EMAIL PROTECTED]> wrote:
> >
> > >>>>> "PH" == Paul Henrich <[EMAIL PROTECTED]> writes:
> >
> > PH> You might check to make sure that you are loading PK::Auto in
> > PH> MyAppDB::MyTable:
> >
> > I belive that with a recent DBIx::Class that's not necessary: perldoc
> > DBIx::Class::PK::Auto indicates that "PK::Auto is now part of Core."
> >
> >
> > k.
> >
> > --
> > kevin montuori
> > [EMAIL PROTECTED]
> >
> > _______________________________________________
> > List: [email protected]
> > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> > Searchable archive:
> > http://www.mail-archive.com/[EMAIL PROTECTED]/
> > Dev site: http://dev.catalyst.perl.org/
> >
>
>
>
> --
> Regards,
> Martin
> ([EMAIL PROTECTED])
> IT: http://methodsupport.com Personal: http://thereisnoend.org
>



-- 
Regards,
Martin
([EMAIL PROTECTED])
IT: http://methodsupport.com Personal: http://thereisnoend.org
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to