Tom Simon
2008-Feb-26 17:03 UTC
Rails 2.0.2 MySQL ''year'' datatype missing from ActiveRecord?
Hi all, This is my first post to the forum, and I''ll point out right away that I''m a noob to everything, Ruby, Rails, MySQL, etc., so I expect that I''m wrong here, but is the ''year'' datatype missing from ActiveRecord in 2.0.2? According to my MySQL 5.0 reference manual, ''year'' is a datatype, but when I try to run a migration that has a t.year column, I get this: rake aborted! undefined method `year'' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x274a070> I opened up the mysql_adapter.rb file in my frozen 2.0.2 ActiveRecord, and sure enough, ''year'' was missing from the native_database_types hash, so I added it. rake db:migrate still doesn''t work (continues to give the same error, and I can''t find the TableDefinition), however. Any suggestions? I can of course use a ''date'' as a workaround, but I''m building a discography, and ''year'' is all I need. Thanks, Tom -- 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Feb-26 17:28 UTC
Re: Rails 2.0.2 MySQL ''year'' datatype missing from ActiveRecord?
On 26 Feb 2008, at 17:03, Tom Simon wrote:> > Hi all, > > This is my first post to the forum, and I''ll point out right away that > I''m a noob to everything, Ruby, Rails, MySQL, etc., so I expect that > I''m > wrong here, but is the ''year'' datatype missing from ActiveRecord in > 2.0.2? According to my MySQL 5.0 reference manual, ''year'' is a > datatype, > but when I try to run a migration that has a t.year column, I get > this: > > rake aborted! > undefined method `year'' for > #<ActiveRecord::ConnectionAdapters::TableDefinition:0x274a070> >why not use an integer?> I opened up the mysql_adapter.rb file in my frozen 2.0.2 ActiveRecord, > and sure enough, ''year'' was missing from the native_database_types > hash, > so I added it. rake db:migrate still doesn''t work (continues to give > the > same error, and I can''t find the TableDefinition), however. Any > suggestions? I can of course use a ''date'' as a workaround, but I''m > building a discography, and ''year'' is all I need. > > Thanks, > Tom > -- > 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 > -~----------~----~----~----~------~----~------~--~--- >
Philip Hallstrom
2008-Feb-26 17:33 UTC
Re: Rails 2.0.2 MySQL ''year'' datatype missing from ActiveRecord?
> This is my first post to the forum, and I''ll point out right away that > I''m a noob to everything, Ruby, Rails, MySQL, etc., so I expect that I''m > wrong here, but is the ''year'' datatype missing from ActiveRecord in > 2.0.2? According to my MySQL 5.0 reference manual, ''year'' is a datatype, > but when I try to run a migration that has a t.year column, I get this: > > rake aborted! > undefined method `year'' for > #<ActiveRecord::ConnectionAdapters::TableDefinition:0x274a070> > > I opened up the mysql_adapter.rb file in my frozen 2.0.2 ActiveRecord, > and sure enough, ''year'' was missing from the native_database_types hash, > so I added it. rake db:migrate still doesn''t work (continues to give the > same error, and I can''t find the TableDefinition), however. Any > suggestions? I can of course use a ''date'' as a workaround, but I''m > building a discography, and ''year'' is all I need.I don''t believe that ''year'' is a standard sql type so I suspect that Rails is intentionally not putting it in there as what you''ve just done won''t work with other databases... If all you need is the number, just make it an :integer. -philip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Leonardo
2008-Feb-26 17:44 UTC
Re: Rails 2.0.2 MySQL ''year'' datatype missing from ActiveRecord?
Something similar happens with the DB2 XML data type. I described the problem here: http://leonardoborges.com/writings/2008/01/02/rails-20-xml-data-type-and-db2/ The bottom line is that the sexy migrations doesn''t work with the xml data type. So instead of: t.xml :column_name I had to do: t.column :data, :xml thus making use of the old syntax. It might work in your case as well. Give it a try. Hope this helps On Feb 26, 2:33 pm, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote:> > This is my first post to the forum, and I''ll point out right away that > > I''m a noob to everything, Ruby, Rails, MySQL, etc., so I expect that I''m > > wrong here, but is the ''year'' datatype missing from ActiveRecord in > > 2.0.2? According to my MySQL 5.0 reference manual, ''year'' is a datatype, > > but when I try to run a migration that has a t.year column, I get this: > > > rake aborted! > > undefined method `year'' for > > #<ActiveRecord::ConnectionAdapters::TableDefinition:0x274a070> > > > I opened up the mysql_adapter.rb file in my frozen 2.0.2 ActiveRecord, > > and sure enough, ''year'' was missing from the native_database_types hash, > > so I added it. rake db:migrate still doesn''t work (continues to give the > > same error, and I can''t find the TableDefinition), however. Any > > suggestions? I can of course use a ''date'' as a workaround, but I''m > > building a discography, and ''year'' is all I need. > > I don''t believe that ''year'' is a standard sql type so I suspect that Rails > is intentionally not putting it in there as what you''ve just done won''t > work with other databases... > > If all you need is the number, just make it an :integer. > > -philip--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
redhawkie
2008-Feb-26 23:56 UTC
Re: Rails 2.0.2 MySQL ''year'' datatype missing from ActiveRecord?
Thanks, this makes sense. I agree that an integer is the way to go, but I figured that if it existed in MySQL I might as well use it. But if it''s specific only to MySQL, then I understand why it''s not there. Is there a place in the API/docs where this kind of stuff is listed/ explained? On Feb 26, 12:33 pm, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote:> > This is my first post to the forum, and I''ll point out right away that > > I''m a noob to everything, Ruby, Rails, MySQL, etc., so I expect that I''m > > wrong here, but is the ''year'' datatype missing from ActiveRecord in > > 2.0.2? According to my MySQL 5.0 reference manual, ''year'' is a datatype, > > but when I try to run a migration that has a t.year column, I get this: > > > rake aborted! > > undefined method `year'' for > > #<ActiveRecord::ConnectionAdapters::TableDefinition:0x274a070> > > > I opened up the mysql_adapter.rb file in my frozen 2.0.2 ActiveRecord, > > and sure enough, ''year'' was missing from the native_database_types hash, > > so I added it. rake db:migrate still doesn''t work (continues to give the > > same error, and I can''t find the TableDefinition), however. Any > > suggestions? I can of course use a ''date'' as a workaround, but I''m > > building a discography, and ''year'' is all I need. > > I don''t believe that ''year'' is a standard sql type so I suspect that Rails > is intentionally not putting it in there as what you''ve just done won''t > work with other databases... > > If all you need is the number, just make it an :integer. > > -philip--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom
2008-Feb-27 01:44 UTC
Re: Rails 2.0.2 MySQL ''year'' datatype missing from ActiveRecord?
> Thanks, this makes sense. I agree that an integer is the way to go, > but I figured that if it existed in MySQL I might as well use it. But > if it''s specific only to MySQL, then I understand why it''s not there. > Is there a place in the API/docs where this kind of stuff is listed/ > explained?http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/TableDefinition.html#M001222> > > On Feb 26, 12:33 pm, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote: >>> This is my first post to the forum, and I''ll point out right away that >>> I''m a noob to everything, Ruby, Rails, MySQL, etc., so I expect that I''m >>> wrong here, but is the ''year'' datatype missing from ActiveRecord in >>> 2.0.2? According to my MySQL 5.0 reference manual, ''year'' is a datatype, >>> but when I try to run a migration that has a t.year column, I get this: >> >>> rake aborted! >>> undefined method `year'' for >>> #<ActiveRecord::ConnectionAdapters::TableDefinition:0x274a070> >> >>> I opened up the mysql_adapter.rb file in my frozen 2.0.2 ActiveRecord, >>> and sure enough, ''year'' was missing from the native_database_types hash, >>> so I added it. rake db:migrate still doesn''t work (continues to give the >>> same error, and I can''t find the TableDefinition), however. Any >>> suggestions? I can of course use a ''date'' as a workaround, but I''m >>> building a discography, and ''year'' is all I need. >> >> I don''t believe that ''year'' is a standard sql type so I suspect that Rails >> is intentionally not putting it in there as what you''ve just done won''t >> work with other databases... >> >> If all you need is the number, just make it an :integer. >> >> -philip > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---