There is a table:
execute (<<-SQL)
CREATE TABLE "tasks" (
"id" serial primary key,
"number" serial,
"version" integer DEFAULT 0 NOT NULL,
"latest_version" boolean DEFAULT 't' NOT NULL,
"hidden" boolean DEFAULT 'f' NOT NULL,
"type" character varying (1) NOT NULL,
"created_at" timestamp
);
SQL
I need the number field to be serial, i.e. to be automatically filled
when mising it in the hash for create method. I had to write sql-code,
because for postgresql adapter cannot create serial-fields. But in
this case when trying to add
task = Task.create ( :type => "c")
error is raised:
PGError: ERROR: null value in column "number" violates not-null
constraint
: INSERT INTO "tasks" ( "number", "latest_version", "type", "version",
"hidden", "created_at") VALUES (NULL, 't', E'c ', 0,' f ', '2009-09-07
08:43:13.534476 ') RETURNING "id"
i.e. NULL is specified for number field. Can I exclude the number
field from the list for INSERT or maybe there is any other more
correct way to cope with it?
Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---