I''m mapping a new RoR application onto an existing Oracle schema. The tables *usually* have a primary key named *id*, but the sequences that assign new id values don''t have Rails-convention names. Is there a way to tell Rails that the sequence for table FOO is not FOO_SEQ, but XYZ_SEQ? If that''s not possible, is there a way to create the equivalent of a table''s *view*, but for a sequence? Looking forward to any suggestions. Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I got an answer from Railsfrance: set_sequence_name(value = nil, &block) can be used. I hadn''t been able to find the word "sequence" in the index of the AWDwR2 book... On Aug 13, 4:36 pm, gers32 <cbu.ki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m mapping a new RoR application onto an existing Oracle schema. The > tables *usually* have a primary key named *id*, but the sequences that > assign new id values don''t have Rails-convention names. Is there a way > to tell Rails that the sequence for table FOO is not FOO_SEQ, but > XYZ_SEQ? > > If that''s not possible, is there a way to create the equivalent of a > table''s *view*, but for a sequence? > > Looking forward to any suggestions. Thanks.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
gene.tani-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Aug-13 17:09 UTC
Re: Existing Oracle schema with its own sequence
On Aug 13, 8:06 am, gers32 <cbu.ki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I got an answer from Railsfrance: set_sequence_name(value = nil, > &block) can be used. I hadn''t been able to find the word "sequence" in > the index of the AWDwR2 book... >i think you want to Google for "legacy app" or "legacy schema" There''s quite a few blogs and threads here. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yes, I did search the site for these keywords and other combinations. I couldn''t find an answer to my follow-up question: The legacy Oracle schema uses triggers to get the sequences'' next values. Isn''t there a potential conflict with Rails'' mechanism during record creation? If so, should I tell Rails to use the existing trigger mechanism (and how), or should I deactivate the triggers exclusively for my application - the tables are being accessed by other legacy apps - (and how)? Last thought : I''m going to create views, so that I can use the Rails naming conventions. Maybe that solves my problem, assuming I can link the sequence to the view? You can tell I''m new both to RoR and Oracle, can''t you... Thanks, Chris. Le mécanisme d''affectation des clés primaires n''est pas clair, dans le contexte de ma base existante : celle-ci utilise des "triggers" pour récupérer la nouvelle valeur dans la séquence. Comment éviter un conflit entre ceux-ci et Rails, lors de la création d''un nouvel enregistrement ? Dois-je dire à Rails d''utiliser le mécanisme existant (via "triggers") et comment ? Ou alors, dois-je inactiver les "triggers" pour mon application (sachant que d''autres applis ont accès à la même base) et comment ? RoR et Oracle sont nouveaux pour moi ; ça se voit, non ? On Aug 13, 7:09 pm, "gene.t...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <gene.t...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Aug 13, 8:06 am,gers32<cbu.ki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I got an answer from Railsfrance: set_sequence_name(value = nil, > > &block) can be used. I hadn''t been able to find the word "sequence" in > > the index of the AWDwR2 book... > > i think you want to Google for "legacy app" or "legacy schema" > There''s quite a few blogs and threads here.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I have the same question (i.e., conflicts with oracle triggers and rails). Also, I am finding that I have the following problem using legacy sequences with non-rails names: Even if I do set_sequence_name in the model, and even if I create the proper sequences in my migrations, when I run rake test, rails wipes out my test database and recreates it without the custom sequences (though they exist in the development db), so I always get a "sequence does not exist" in my create tests. Is there some way to use the test_helper to hook into the test case scenarios and fix this before the tests run? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Here''s my solution: <a href="http://weenet.blogspot.com/2007/09/non- standard-sequences-and-rails-tests.html#links">weeblog: Non-Standard Sequences and Rails Tests</a> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Here''s the solution I came up with (for the testing issue): http://weenet.blogspot.com/2007/09/non-standard-sequences-and-rails-tests.html#links --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---