[Dbix-class] creating a row that's empty but for an auto-incremented key?
Ash Berlin
ash at cpan.org
Sat Jul 8 17:37:30 CEST 2006
John Siracusa wrote:
> On 7/8/06 11:22 AM, Ash Berlin wrote:
>
>> John Siracusa wrote:
>>
>>> 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.
>>>
>> To do that in DBIx:
>>
>> $rs->create({ anycol => \'DEFAULT' });
>>
>> But still not portable
>>
>
> When I said "constructed on a case-by-case basis," I meant by the library,
> not the user. So you'd do this:
>
> $rs->create({});
>
> and it'd Do The Right Thing for whatever db $rs is connected to.
>
> (or $rs->create(), if that's not too scary for some people :)
> -John
>
>
Agreed - simply noting it in case George wants to get on with it :)
More information about the Dbix-class
mailing list