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

Marnen Laibow-Koser
Wed, 21 Oct 2009 21:10:35 -0000

Marnen Laibow-Koser wrote:
> Marnen Laibow-Koser wrote:
>> JeffV wrote:
>>> The downside is pretty large: it doesn''t work if I define
a composite
>>> PK. If you read my posting above you''ll see that I get a
Postgres
>>> adapter error on the RETURNING statement.
>>
>> No, your posting above says that you get the error when you define a
>> *nil* PK, not a *composite* one.
>>
>
> My mistake.  I missed a post where you *did* say this.  Doing some
> research...

Research done.  I created a sample app testing composite_primary_keys,
which is up on Github at http://github.com/marnen/cpk_sample if you want
to play around with it.  The app uses one table (entries) with three
integer fields (alpha, beta, gamma) and no id field.  There are several
branches:

* no_index_nil_keys -- no index on DB table, Entry.set_primary_keys nil.
Doesn''t work.

* no_index_all_keys -- no index on DB table, Entry.set_primary_keys
:alpha, :beta, :gamma. Works for reading and writing (that is,
Entry.create and Entry.all both work as expected).

* all_index_all_keys -- primary key(alpha beta gamma) on DB table,
Entry.set_primary_keys :alpha, :beta, :gamma.  Works for reading and
writing.

I think you were getting the error in a no_index_all_keys situation, and
I cannot reproduce that error.  I''m using Mac OS X 10.6.1, Ruby 1.8.7,
Rails 2.3.4, composite_primary_keys 2.3.2, and PostgreSQL 8.4.1.  Let me
know if you get different results with my code...

> Best,
> --
> Marnen Laibow-Koser
> http://www.marnen.org
> marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org

--
Posted via http://www.ruby-forum.com/.