Hello. This is a new post for a message I didn''t get any answers to. I hope this post catches somebody''s eye and helps me with the issue. Sorry for the duplication but this is driving me nuts. The environment is: - Ruby version is 1.8.6 - Rails version is 1.2.3. - Database is Oracle (10g) in which I have a table with one defined as: MY_FIELD NUMBER(1,0) DEFAULT ''2'' When a record is created in the database the value that invariable gets posted to the table is 0 (zero) instead of 2. However, if I change the field to: MY_FIELD NUMBER(2,0) DEFAULT ''2'', the default value of 2 is correctly posted. Is there a reason Rails would override the value for a NUMBER(1,0) field? Is it believing that the field is a true/false container and changes the default to a 0 (zero) since it is not a 1 (''true'')? Any ideas why this is happening and/or how to solve it short of modifying the column''s length? Thanks in advance. Pepe --~--~---------~--~----~------------~-------~--~----~ 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 5 Sep 2008, at 14:39, pepe wrote:> > Hello. > > This is a new post for a message I didn''t get any answers to. I hope > this post catches somebody''s eye and helps me with the issue. Sorry > for the duplication but this is driving me nuts. > > The environment is: > - Ruby version is 1.8.6 > - Rails version is 1.2.3. > - Database is Oracle (10g) in which I have a table with one defined > as: > MY_FIELD NUMBER(1,0) DEFAULT ''2'' > > When a record is created in the database the value that invariable > gets posted to the table is 0 (zero) instead of 2. However, if I > change the field to: > MY_FIELD NUMBER(2,0) DEFAULT ''2'', the default value of 2 is > correctly posted. > > Is there a reason Rails would override the value for a NUMBER(1,0) > field? Is it believing that the field is a true/false container and > changes the default to a 0 (zero) since it is not a 1 (''true'')? > > Any ideas why this is happening and/or how to solve it short of > modifying the column''s length?Well the mysql adapter has a MysqlAdapter.emulate_booleans setting that does that with tinyint(1) columns. The oracle adapter could conceivably be doing the same thing - check the source! Fred> > > Thanks in advance. > > Pepe > >--~--~---------~--~----~------------~-------~--~----~ 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 Fred. Pepe On Sep 5, 9:42 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 5 Sep 2008, at 14:39, pepe wrote: > > > > > > > > > > > Hello. > > > This is a new post for a message I didn''t get any answers to. I hope > > this post catches somebody''s eye and helps me with the issue. Sorry > > for the duplication but this is driving me nuts. > > > The environment is: > > - Ruby version is 1.8.6 > > - Rails version is 1.2.3. > > -Databaseis Oracle (10g) in which I have a table with one defined > > as: > > MY_FIELD NUMBER(1,0)DEFAULT''2'' > > > When a record is created in thedatabasethe value that invariable > > gets posted to the table is 0 (zero) instead of 2. However, if I > > change the field to: > > MY_FIELD NUMBER(2,0)DEFAULT''2'', thedefaultvalue of 2 is > > correctly posted. > > > Is there a reason Rails would override the value for a NUMBER(1,0) > > field? Is it believing that the field is a true/false container and > > changes thedefaultto a 0 (zero) since it is not a 1 (''true'')? > > > Any ideas why this is happening and/or how to solve it short of > > modifying the column''s length? > > Well the mysql adapter has a MysqlAdapter.emulate_booleans setting > that does that with tinyint(1) columns. > > The oracle adapter could conceivably be doing the same thing - check > the source! > > Fred > > > > > Thanks in advance. > > > Pepe--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks Fred, I found what I was looking for. I found the code for the adapter and these 2 lines are pretty revealing: return :boolean if OracleAdapter.emulate_booleans && field_type == ''NUMBER(1)'' @@emulate_booleans = true Thanks a lot for your help. :) Pepe On Sep 5, 9:42 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 5 Sep 2008, at 14:39, pepe wrote: > > > > > > > Hello. > > > This is a new post for a message I didn''t get any answers to. I hope > > this post catches somebody''s eye and helps me with the issue. Sorry > > for the duplication but this is driving me nuts. > > > The environment is: > > - Ruby version is 1.8.6 > > - Rails version is 1.2.3. > > -Databaseis Oracle (10g) in which I have a table with one defined > > as: > > MY_FIELD NUMBER(1,0)DEFAULT''2'' > > > When a record is created in thedatabasethe value that invariable > > gets posted to the table is 0 (zero) instead of 2. However, if I > > change the field to: > > MY_FIELD NUMBER(2,0)DEFAULT''2'', thedefaultvalue of 2 is > > correctly posted. > > > Is there a reason Rails would override the value for a NUMBER(1,0) > > field? Is it believing that the field is a true/false container and > > changes thedefaultto a 0 (zero) since it is not a 1 (''true'')? > > > Any ideas why this is happening and/or how to solve it short of > > modifying the column''s length? > > Well the mysql adapter has a MysqlAdapter.emulate_booleans setting > that does that with tinyint(1) columns. > > The oracle adapter could conceivably be doing the same thing - check > the source! > > Fred > > > > > Thanks in advance. > > > Pepe--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---