Last active
December 8, 2016 10:23
-
-
Save kml/4c76c22df26a1fa372c97aff93e873ab to your computer and use it in GitHub Desktop.
Modifies ::BSON::ByteBuffer#get_int64 to return Fixnum not Bignum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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