Skip to content

Instantly share code, notes, and snippets.

@kml
Last active December 8, 2016 10:23
Show Gist options
  • Save kml/4c76c22df26a1fa372c97aff93e873ab to your computer and use it in GitHub Desktop.
Save kml/4c76c22df26a1fa372c97aff93e873ab to your computer and use it in GitHub Desktop.
Modifies ::BSON::ByteBuffer#get_int64 to return Fixnum not Bignum
# ByteBuf#getInt64 should return Fixnum not Bignum
# Issue: https://jira.mongodb.org/browse/RUBY-1189
# Example: http://pastie.org/10978801#1,14,17,19,25
# Gist: https://gist.github.com/kml/4c76c22df26a1fa372c97aff93e873ab
require "bson"
unless BSON::ByteBuffer.new(2200000227.to_bson.to_s).get_int64.is_a?(Bignum)
abort "#{__FILE__}: BSON::ByteBuffer#get_int64 already fixed! Remove this patch."
end
::BSON::ByteBuffer.class_eval do
alias :get_int64_bignum :get_int64
def get_int64
org.jruby.RubyBignum.big2long(get_int64_bignum)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment