Adds bigint/long support to address #61

This commit is contained in:
Karl Southern
2016-09-15 11:06:34 +01:00
parent ffb2f700be
commit 47fdf7d442
5 changed files with 15 additions and 6 deletions

View File

@@ -280,7 +280,13 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
# strftime appears to be the most reliable across drivers.
statement.setString(idx + 1, value.time.strftime(STRFTIME_FMT))
when Fixnum, Integer
statement.setInt(idx + 1, value)
# bit_length doesn't exist in the current version of ruby/jruby logstash targets
# and this seems quicker than doing some Math.log2(value < 0 ? -value : value+1).ceil shit
if value > 2147483647 or value < -2147483648
statement.setLong(idx + 1, value)
else
statement.setInt(idx + 1, value)
end
when Float
statement.setFloat(idx + 1, value)
when String