106: def columns(table)
107: @db.type_translation = false
108: ret =
109: @db.table_info(table).map do |hash|
110: m = DBI::DBD::SQLite3.parse_type(hash['type'])
111: h = {
112: 'name' => hash['name'],
113: 'type_name' => m[1],
114: 'sql_type' =>
115: begin
116: DBI.const_get('SQL_'+hash['type'].upcase)
117: rescue NameError
118: DBI::SQL_OTHER
119: end,
120: 'nullable' => (hash['notnull'] == '0'),
121: 'default' => (@attr['type_translation'] && (not hash['dflt_value'])) ?
122: @db.translator.translate(hash['type'], hash['dflt_value']) :
123: hash['dflt_value']
124: }
125:
126: h['precision'] = m[3].to_i if m[3]
127: h['scale'] = m[5].to_i if m[5]
128:
129: h
130: end
131: @db.type_translation = @attr['type_translation']
132: ret
133: end