Hi,
Doing connection.pk_and_sequence_for doesn''t return anything when
I''m
positive I''ve got a PK and sequence on my table on column
"id", see DDL
below. Is this a bug?
?> Player.primary_key
=> "id"
>> Player.connection.default_sequence_name "players"
=> "players_id_seq"
>> Player.connection.pk_and_sequence_for "players"
=> nil
>>
Here''s what RoR sends to the postgresql server with this last method
call
LOG: statement: SELECT attr.attname, (name.nspname ||
''.'' ||
seq.relname)
FROM pg_class seq,
pg_attribute attr,
pg_depend dep,
pg_namespace name,
pg_constraint cons
WHERE seq.oid = dep.objid
AND seq.relnamespace = name.oid
AND seq.relkind = ''S''
AND attr.attrelid = dep.refobjid
AND attr.attnum = dep.refobjsubid
AND attr.attrelid = cons.conrelid
AND attr.attnum = cons.conkey[1]
AND cons.contype = ''p''
AND dep.refobjid =
''players''::regclass
DDL:
CREATE TABLE "public"."players" (
"id" SERIAL,
"positie" INTEGER,
"active" BOOLEAN DEFAULT false NOT NULL,
"perm_level" SMALLINT DEFAULT 1 NOT NULL,
"email" VARCHAR(150) NOT NULL,
"fname" VARCHAR(60) NOT NULL,
"lname" VARCHAR(80) NOT NULL,
..
..
CONSTRAINT "players_pkey" PRIMARY KEY("id")
) WITH OIDS;
CREATE SEQUENCE "public"."players_id_seq"
INCREMENT 1 MINVALUE 1
MAXVALUE 32767 START 16
CACHE 1;
Any ideas??
Jeroen