Detect column type?

Using column_names I can get a nice list of columns in a table, but is
there any way to detect the column type? Like “string”, “integer”,
“boolean”, etc?

On 10 Jan 2009, at 17:11, Taylor S.
<[email protected]

wrote:

Using column_names I can get a nice list of columns in a table, but is
there any way to detect the column type? Like “string”, “integer”,
“boolean”, etc?

The columns method returns an array of column objects, which among
other things, has the name and type of the corresponding column.

Fred

Frederick C. wrote:

On 10 Jan 2009, at 17:11, Taylor S.
<[email protected]

wrote:

Using column_names I can get a nice list of columns in a table, but is
there any way to detect the column type? Like “string”, “integer”,
“boolean”, etc?

The columns method returns an array of column objects, which among
other things, has the name and type of the corresponding column.

Fred

Indeed. It returns the below for an id column. Thanks.

#<ActiveRecord::ConnectionAdapters::SQLiteColumn:0x23736b8
@precision=nil, @primary=true, @default=nil, @limit=nil, @type=:integer,
@null=false, @name=“id”, @scale=nil, @sql_type=“INTEGER”>