Forum: Ruby on Rails Table without primary key

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Step (Guest)
on 2007-02-13 13:51
Hi all.
I have table without in my DB.
Rails try to use non-existent sequence and try to write value into
non-existent primary key. And i have DB error.
How to use model with such table?
I try
  set_sequence_name nil
    set_primary_key nil
and
    set_sequence_name ""
    set_primary_key ""
 - not works.
Help me please.
Bye.
Jens (Guest)
on 2007-02-13 14:03
(Received via mailing list)
Hi,

Why don't you just add a primary key?
If you don't have a primary key, how do you find entries in the
database?

Jens
Step (Guest)
on 2007-02-13 14:18
> Why don't you just add a primary key?

I can not modify DB. I did not create DB. I use it only.

> If you don't have a primary key, how do you find entries in the
> database?
I  use SQL :)
You can create table without PK and you will be able to get data :)
step (Guest)
on 2007-02-13 14:37
(Received via mailing list)
> Why don't you just add a primary key?
I did not create DB. I can't modify it, only use.
> If you don't have a primary key, how do you find entries in the database?
I use SQL :)
Craig D. (Guest)
on 2007-02-13 14:38
(Received via mailing list)
On Feb 13, 2007, at 7:18 AM, Step wrote:

>
>> Why don't you just add a primary key?
>
> I can not modify DB. I did not create DB. I use it only.

Since I don't know the answer, I'll ask Step's question another way:
why not ask the DBA to add a primary key?

>
>> If you don't have a primary key, how do you find entries in the
>> database?
> I  use SQL :)
> You can create table without PK and you will be able to get data :)

Of course. I think what Step wanted to know was what criteria do you
use to find unique rows?

Craig
Craig D. (Guest)
on 2007-02-13 14:39
(Received via mailing list)
Oops. In my earlier reply, I meant to reference Jens' questions
instead of Step's. I'm sorry for any confusion.

Craig
Step (Guest)
on 2007-02-13 16:29
Win with
set_primary_keys - tool for composite primary key

gem --install composite_primary_keys
Craig D. (Guest)
on 2007-02-13 16:42
(Received via mailing list)
On Feb 13, 2007, at 9:29 AM, Step wrote:

>
> Win with
> set_primary_keys - tool for composite primary key
>
> gem --install composite_primary_keys

I agree that this is a great gem, but you wrote that your table
didn't have a primary key. Did you or a DBA create a compound one
instead of a simple one? Or, did you have a compound one all along?

Craig
step (Guest)
on 2007-02-14 10:46
(Received via mailing list)
> Did you or a DBA create a compound one  instead of a simple one?
>Or, did you have a compound one all along?
No.
Table had not any PK.
Table has not any PK now.
 I tried use set_primary_key :column_name but it didn't work. When i
tried to save row i had got error. I don't know why.
 I tried use this gem and use set_primary_keys :column_name - it
works.
This topic is locked and can not be replied to.