Joshua D. Drake wrote:
On 01/03/07, Andrew Madu < [EMAIL PROTECTED]> wrote:
Hi Dave,
my apologies for contacting you off list but i'm having a spot of bother
with postgreSQL sequence setup in rails. In addition to what is mentioned
below, I have place the following line of code in my

The definition of primary key explicitly states that it can't be null.
You are trying to pass a null to user_id which won't work.

Joshua D. Drkae


In MySQL that is traditionally how you tell the RDBMS to use the auto_increment to generate the value. Postgres correctly doesn't allow that (since you might actually try to set a field to NULL accidentally in which case an error is expected).

The portable (and correct) way to do it is to use the DEFAULT keyword like this:

INSERT INTO some_table (id_field) VALUES (DEFAULT);

I just tested on MySQL 5.0.32 and that syntax works fine.

--

Russ.

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to