The example Brett Gardner gave is equivalent to ->create({ bar =>  
'bar' }). create() is just new() followed by insert. The issue of  
wanting to insert a row with *no* values specified is a more general  
one, however. In many cases it's probably bad design to need to do  
something like that. But the reason it doesn't work is, first of all,  
that SQL::Abstract doesn't give the right syntax for it, and secondly  
-- there doesn't seem to be a single "right syntax" for it. "INSERT  
INTO foo;" doesn't work for all databases. Some allow "INSERT INTO  
foo DEFAULT VALUES;", but I believe that produces an error in mysql.  
So we haven't found a general solution yet which is the right way of  
handling it.

Dave

On Jul 8, 2006, at 3:42 AM, George Hartzell wrote:

> Brett Gardner writes:
>> if you do
>>
>> $foo = $schema->resultset('Foo')->new({});
>> $foo->bar('bar');
>> $foo->insert;
>
> Thanks, that should work for what I'm trying to do.
>
> Even with this approach, it's still not possible to insert a row in
> which all of the columns except the primary key are non-existent/NULL
> and have the key be automagically generated via PK::Auto, right?
>
> Thanks again,
>
> g.

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to