[Dbix-class] creating a row that's empty but for an auto-incremented key?

Ash Berlin ash at cpan.org
Sat Jul 8 17:22:44 CEST 2006


John Siracusa wrote:
> On 7/8/06 12:35 AM, David Kamholz wrote:
>   
>> -- 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.
>>     
>
> Another alternative is:
>
>     INSERT INTO foo (anycol) VALUES (DEFAULT);
>
> That works in MySQL and Postgres, where anycol is literally any column in
> the table.
>
> That said, so far, I haven't found a syntax that works "everywhere."  This
> type of thing has to be constructed on a case-by-case basis for each db.
>
> -John
>
>
>
> _______________________________________________
> 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/dbix-class@lists.rawmode.org/
>   
To do that in DBIx:

$rs->create({ anycol => \'DEFAULT' });

But still not portable

Ash




More information about the Dbix-class mailing list