lib/forklift/transports/mysql.rb in forklift_etl-1.1.4 vs lib/forklift/transports/mysql.rb in forklift_etl-1.1.5
- old
+ new
@@ -105,10 +105,11 @@
end
def sql_type(v)
return "bigint(20)" if v.class == Fixnum
return "float" if v.class == Float
+ return "float" if v.class == BigDecimal
return "date" if v.class == Date
return "datetime" if v.class == Time
return "datetime" if v.class == DateTime
return "varchar(255)" if v.class == Symbol
return "tinyint(1)" if v.class == TrueClass
@@ -228,11 +229,11 @@
end
if !value.nil?
sql_type = sql_type(value)
alter_sql = "ALTER TABLE `#{database}`.`#{table}` CHANGE `#{row[:Field]}` `#{row[:Field]}` #{sql_type};"
- puts alter_sql
+ forklift.logger.log alter_sql
q(alter_sql)
end
end
end
@@ -267,10 +268,10 @@
elsif( [::Date, ::Time, ::DateTime].include?(v.class) )
s = v.to_s(:db)
part = "\"#{s}\""
elsif( [::Fixnum].include?(v.class) )
part = v
- elsif( [::Float].include?(v.class) )
+ elsif( [::Float, ::BigDecimal].include?(v.class) )
part = v.to_f
end
a << part
end
return a.join(', ')