Hi everyone, I''m working on a new rails project and have to build it on top of a legacy oracle database. I''m trying to figure out how to get the number value from a NUMBER(1) datatype. So far I''m only getting a "true" value for 1 and "false" for any other number. From the console I can print out my object values and can see that there are number values in the object, but whenever I try to access the value from a method, it converts to boolean. Is there a way to force the method to return the actual number value? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Look in oracle_adapter.rb (it should be in your vendor/ directory if you''ve forzen rails) and you''ll notice that it specifically maps, if my memory of Oracle and AR don''t fail me, NUMBER(1)''s to boolean values because the built-in Oracle boolean field (is there one? that I cannot remember) is not supported at current. It also does some funky mapping with DATE columns regarding 00:00:00 as the time portion. Be careful with rails and Oracle they work great if you know the caveats but they can bite you if you don''t. It should be noted I haven''t written a line of ruby in almost six months so my knowledge is dated. On Aug 3, 12:09 pm, "d.ryan" <dry...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi everyone, > > I''m working on a new rails project and have to build it on top of a > legacy oracle database. I''m trying to figure out how to get the > number value from a NUMBER(1) datatype. So far I''m only getting a > "true" value for 1 and "false" for any other number. From the console > I can print out my object values and can see that there are number > values in the object, but whenever I try to access the value from a > method, it converts to boolean. Is there a way to force the method to > return the actual number value?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks for the quick response Chris! You pointed me in the right direction. I had to add this line to the environment.rb file: ActiveRecord::ConnectionAdapters::OracleAdapter.emulate_booleans false On Aug 3, 10:52 am, Chris <wade.christop...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Look in oracle_adapter.rb (it should be in your vendor/ directory if > you''ve forzen rails) and you''ll notice that it specifically maps, if > my memory of Oracle and AR don''t fail me, NUMBER(1)''s to boolean > values because the built-in Oracle boolean field (is there one? that I > cannot remember) is not supported at current. It also does some funky > mapping with DATE columns regarding 00:00:00 as the time portion. Be > careful with rails and Oracle they work great if you know the caveats > but they can bite you if you don''t. > > It should be noted I haven''t written a line of ruby in almost six > months so my knowledge is dated. > > On Aug 3, 12:09 pm, "d.ryan" <dry...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi everyone, > > > I''m working on a new rails project and have to build it on top of a > > legacy oracle database. I''m trying to figure out how to get the > > number value from a NUMBER(1) datatype. So far I''m only getting a > > "true" value for 1 and "false" for any other number. From the console > > I can print out my object values and can see that there are number > > values in the object, but whenever I try to access the value from a > > method, it converts to boolean. Is there a way to force the method to > > return the actual number value?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---