I have a small table that is used to temporarily queue requests, as such it does not have an id field (or any other primary key), because it doesn''t make sense to have one. When I created an ActiveRecord class and tried to save it, I get: ActiveRecord::StatementInvalid: PGError: ERROR: relation "temp_requests_id_seq" does not exist It keeps looking for the id to auto increment, even though it doesn''t exist. Any suggestions on how to overcome this? Thanks! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Does your migration have something like this in it? create_table :roles_users, :id => false do |t| On Aug 23, 3:00 pm, First Last <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I have a small table that is used to temporarily queue requests, as such > it does not have an id field (or any other primary key), because it > doesn''t make sense to have one. > > When I created an ActiveRecord class and tried to save it, I get: > > ActiveRecord::StatementInvalid: PGError: ERROR: relation > "temp_requests_id_seq" does not exist > > It keeps looking for the id to auto increment, even though it doesn''t > exist. > > Any suggestions on how to overcome this? > > Thanks! > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> create_table :roles_users, :id => false do |t|Yes, it has :id => false. Migration works fine, can create object - just can''t save it. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 8/24/07, First Last <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I have a small table that is used to temporarily queue requests, as such > it does not have an id field (or any other primary key), because it > doesn''t make sense to have one. >Sure about that? You won''t be accessing specific/individual entries for any reason whatsoever..? How will you be looking them up without a key, and what do you gain by not having one? Isak> When I created an ActiveRecord class and tried to save it, I get: > > ActiveRecord::StatementInvalid: PGError: ERROR: relation > "temp_requests_id_seq" does not exist > > It keeps looking for the id to auto increment, even though it doesn''t > exist. > > Any suggestions on how to overcome this? > > Thanks! > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> How will you be looking them up without a key, and what do you gain by > not having one?There''re 2 unique keys for that. Since entries are continuously entered/deleted - that would be continuous auto-incrementing and deletion in the sequence table, thousands times a day, which is really not needed. So is there any way to actually make ActiveRecord save without needing an id? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
yaman 666 wrote:>> How will you be looking them up without a key, and what do you gain by >> not having one? > > There''re 2 unique keys for that. Since entries are continuously > entered/deleted - that would be continuous auto-incrementing and > deletion in the sequence table, thousands times a day, which is really > not needed. > > So is there any way to actually make ActiveRecord save without needing > an id?http://compositekeys.rubyforge.org/ class TempRequest < ActiveRecord::Base # set_primary_keys *keys - turns on composite key functionality set_primary_keys :pk1, :pk2 end --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 8/24/07, yaman 666 <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > How will you be looking them up without a key, and what do you gain by > > not having one? > > There''re 2 unique keys for that. Since entries are continuously > entered/deleted - that would be continuous auto-incrementing and > deletion in the sequence table, thousands times a day, which is really > not needed. >Sequences aren''t that expensive. If you did benchmark and find a bottleneck, I doubt the sequence and one additional index is why. If you aren''t already, make sure you bulk all statements that belong together in a transaction block. If the amount of insert/deletes is large, consider tweaking autovacuum settings for that table, and perhaps increase max_fsm_pages to keep track of all the dead tuples.> So is there any way to actually make ActiveRecord save without needing > an id?You don''t need an id column no, but you do need a PK. See AR::Base.set_primary_key. Be aware that you need to use YourModel#id to refer that column. There are also various plugins you could try if you want a composite PK. IMO you really shouldn''t go off the beaten path unless you have a really good reason to, but YMMV.. Isak> -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---