Re: postgres adapater problem with create_table :id => false

Marnen Laibow-Koser
Wed, 21 Oct 2009 07:50:48 -0000

JeffV wrote:
> doc_id is not a PK. An accurate model of the table would be:
> set_primary_key nil

Again: determine a suitable unique index (potentially composite, say,
doc_id and something else) and declare that as your primary key in the
DB.  This will have many advantages and virtually no downside AFAIK.

> But the PG postgres adapter is unhappy with that because it''s
> generating something like:
>   INSERT into the_table VALUES (val1, val2...) RETURNING pk
> when pk is nil the postgres adapter is unhappy.
> For some reason the composite_primary_keys plugin fixes the problem
> (as only a single PK is specified).
> To me the problem is the PG adapter. I don''t know why it uses
> RETURNING in its INSERT statement.

No, the problem is in your insistence that you don''t want a PK.
Really,
any unique index will do the trick.  Stop fighting Rails and good DB
design and declare one. :)

>
> Jeff
>

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org
--
Posted via http://www.ruby-forum.com/.