Wes Gamble
2006-May-31 20:14 UTC
[Rails] ActiveRecord and database metadata. How much can I get?
All, I have need of getting at some underlying database metadata for ActiveRecord descendants. Does anyone know if I can get access to the following attributes of the underlying column for a given ActiveRecord object: Is it a currency object? Is it nullable? Is it a signed int? Is it searchable? Column length Column name Column precision Column scale Column data type - how specific can I get here? I''m ok with digging into the ActiveRecord::Base object if I have to and mucking around with it. I figure this metadata must be lingering somewhere in order for the database operations to work. Thanks, Wes -- Posted via http://www.ruby-forum.com/.
Jean-François
2006-May-31 21:37 UTC
[Rails] ActiveRecord and database metadata. How much can I get?
Hello Wes,> I have need of getting at some underlying database metadata for > ActiveRecord descendants. > > Does anyone know if I can get access to the following attributes of the > underlying column for a given ActiveRecord object: > > Is it a currency object? > Is it nullable? > Is it a signed int? > Is it searchable? > Column length > Column name > Column precision > Column scale > Column data type - how specific can I get here? > > I''m ok with digging into the ActiveRecord::Base object if I have to and > mucking around with it.See AR::Base#columns and AR::Base#columns_hash You can also look at the scaffold generated code to understand how it can be used.> I figure this metadata must be lingering somewhere in order for the > database operations to work.Regards, -- Jean-Fran?ois. -- ? la renverse.
Wes Gamble
2006-Jun-01 04:43 UTC
[Rails] Re: ActiveRecord and database metadata. How much can I get?
Jean-Fran?ois wrote:> Hello Wes, > >> Column length >> Column name >> Column precision >> Column scale >> Column data type - how specific can I get here? >> >> I''m ok with digging into the ActiveRecord::Base object if I have to and >> mucking around with it. > > See AR::Base#columns and AR::Base#columns_hash > You can also look at the scaffold generated code to understand how > it can be used. > >> I figure this metadata must be lingering somewhere in order for the >> database operations to work. > > Regards, > > -- Jean-Fran?ois.Jean-Francois, Thanks for the help. Looking at the sqlserver driver for active record was quite helpful and gave me what I needed. Wes -- Posted via http://www.ruby-forum.com/.