bson_ext 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/ext/cbson/cbson.c +5 -2
  2. data/ext/cbson/version.h +1 -1
  3. metadata +3 -3
@@ -85,6 +85,7 @@ static VALUE InvalidKeyName;
85
85
  static VALUE InvalidStringEncoding;
86
86
  static VALUE InvalidDocument;
87
87
  static VALUE DigestMD5;
88
+ static VALUE RB_HASH;
88
89
 
89
90
  #if HAVE_RUBY_ENCODING_H
90
91
  #include "ruby/encoding.h"
@@ -535,7 +536,8 @@ static void write_doc(buffer_t buffer, VALUE hash, VALUE check_keys, VALUE move_
535
536
  }
536
537
  else {
537
538
  allow_id = 1;
538
- if (strcmp(rb_obj_classname(hash), "Hash") == 0) {
539
+ // Ensure that hash doesn't contain both '_id' and :_id
540
+ if ((rb_obj_classname(hash), "Hash") == 0) {
539
541
  if ((rb_funcall(hash, rb_intern("has_key?"), 1, id_str) == Qtrue) &&
540
542
  (rb_funcall(hash, rb_intern("has_key?"), 1, id_sym) == Qtrue)) {
541
543
  VALUE oid_sym = rb_hash_delete(hash, id_sym);
@@ -561,7 +563,7 @@ static void write_doc(buffer_t buffer, VALUE hash, VALUE check_keys, VALUE move_
561
563
 
562
564
  write_function(key, value, pack_extra(buffer, check_keys));
563
565
  }
564
- } else if (strncmp(rb_obj_classname(hash), "Hash", 4) == 0) {
566
+ } else if (rb_obj_is_kind_of(hash, RB_HASH) == Qtrue) {
565
567
  rb_hash_foreach(hash, write_function, pack_extra(buffer, check_keys));
566
568
  } else {
567
569
  buffer_free(buffer);
@@ -932,6 +934,7 @@ void Init_cbson() {
932
934
  InvalidDocument = rb_const_get(bson, rb_intern("InvalidDocument"));
933
935
  rb_require("bson/ordered_hash");
934
936
  OrderedHash = rb_const_get(bson, rb_intern("OrderedHash"));
937
+ RB_HASH = rb_const_get(bson, rb_intern("Hash"));
935
938
 
936
939
  CBson = rb_define_module("CBson");
937
940
  ext_version = rb_str_new2(VERSION);
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- #define VERSION "1.0.6"
17
+ #define VERSION "1.0.7"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bson_ext
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 6
10
- version: 1.0.6
9
+ - 7
10
+ version: 1.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mike Dirolf