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

2006-07-20 Thread George Hartzell
John Siracusa writes: 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

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

2006-07-08 Thread John Siracusa
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

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

2006-07-08 Thread Ash Berlin
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

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

2006-07-08 Thread John Siracusa
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.

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

2006-07-07 Thread George Hartzell
I'd like to create a row in a table that's empty except for it's primary key column (e.g. 'id'), which should be automatically generated by PK::Auto. I go on to possibly insert things into it and/or have rows in other tables which have it's id as a foreign key. I'm using Postgresql on FreeBSD

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

2006-07-07 Thread Brett Gardner
if you do $foo = $schema-resultset('Foo')-new({}); $foo-bar('bar'); $foo-insert; The $foo-insert is when the INSERT statement is executed, and it will set the primary key column itself. George Hartzell wrote: I'd like to create a row in a table that's empty except for it's primary key column

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

2006-07-07 Thread George Hartzell
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

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

2006-07-07 Thread David Kamholz
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