lib/csvsql/db.rb in csvsql-0.1.4 vs lib/csvsql/db.rb in csvsql-0.1.5

- old
+ new

@@ -61,11 +61,11 @@ private def parser_header(csv_header) csv_header.map do |col, r| name, type = col.strip.split(':') - [name, (type || 'varchar(255)').downcase.to_sym] + [name.gsub(/[\s-]+/, '_'), (type || 'varchar(255)').downcase.to_sym] end end def init_db_by_csv(csv) header = parser_header(csv.readline) @@ -105,10 +105,10 @@ when :int, :integer then val.to_i when :float, :double then val.to_f when :date then "'#{Date.parse(val).to_s}'" when :datetime then "'#{Time.parse(val).strftime('%F %T')}'" else - "'#{val.gsub("'", "''")}'" + "'#{val.to_s.gsub("'", "''")}'" end rescue => e process_sql_error("Parse #{type} val: #{val}", e) end