<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -12,8 +12,9 @@ A couple methods (that you might not run into) require:
   sudo cpan boolean (MongoDB::Collection::ensure_index)
   sudo cpan Digest::MD5 (MongoDB::Connection::authenticate)
 
-And if you want to use dates, you need:
-  sudo cpan DateTime
+Packages needed for different types:
+  dates: DateTime
+  booleans: boolean
 
 
 Then do:</diff>
      <filename>INSTALL</filename>
    </modified>
    <modified>
      <diff>@@ -304,6 +304,14 @@ elem_to_sv (int type, buffer *buf)
     // we should do something with type
     type = *buf-&gt;pos++;
 
+    if (type == 2) {
+      int len2 = *(int*)buf-&gt;pos;
+      if (len2 == len - 4) {
+        len = len2;
+        buf-&gt;pos += INT_32;
+      }
+    }
+
     value = newSVpvn(buf-&gt;pos, len);
     buf-&gt;pos += len;
 
@@ -581,6 +589,24 @@ void perl_mongo_serialize_oid(buffer *buf, char *id) {
   buf-&gt;pos += OID_SIZE;
 }
 
+void perl_mongo_serialize_bindata(buffer *buf, SV *sv)
+{
+  STRLEN len;
+  const char *bytes = SvPVbyte (sv, len);
+
+  // length of length+bindata
+  perl_mongo_serialize_int(buf, len+4);
+  
+  // TODO: type
+  perl_mongo_serialize_byte(buf, 2);
+  
+  // length
+  perl_mongo_serialize_int(buf, len);
+  // bindata
+  perl_mongo_serialize_bytes(buf, bytes, len);
+}
+
+
 /* the position is not increased, we are just filling
  * in the first 4 bytes with the size.
  */
@@ -804,14 +830,9 @@ append_sv (buffer *buf, const char *key, SV *sv, AV *ids)
                 
               }
               else {
-                STRLEN len;
-                const char *bytes = SvPVbyte((SV*)SvRV(sv), len);
-                
                 set_type(buf, BSON_BINARY);
                 perl_mongo_serialize_string(buf, key, strlen(key));
-                perl_mongo_serialize_int(buf, len);
-                perl_mongo_serialize_byte(buf, 2);
-                perl_mongo_serialize_bytes(buf, bytes, len);
+                perl_mongo_serialize_bindata(buf, SvRV(sv));
               }
             }
         } else {
@@ -861,15 +882,9 @@ append_sv (buffer *buf, const char *key, SV *sv, AV *ids)
             case SVt_PVMG:
                 /* Do we need SVt_PVLV here, too? */
                 if (sv_len (sv) != strlen (SvPV_nolen (sv))) {
-                    STRLEN len;
-                    const char *bytes = SvPVbyte (sv, len);
-
                     set_type(buf, BSON_BINARY);
                     perl_mongo_serialize_string(buf, key, strlen(key));
-                    perl_mongo_serialize_int(buf, len);
-		    // TODO: replace with something
-                    perl_mongo_serialize_byte(buf, 2);
-                    perl_mongo_serialize_bytes(buf, bytes, len);
+                    perl_mongo_serialize_bindata(buf, sv);
                 }
                 else {
                     STRLEN len;</diff>
      <filename>perl_mongo.c</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>533280d47ab9a6f7cfcc6061d1d656f32c8b0240</id>
    </parent>
  </parents>
  <author>
    <name>kristina</name>
    <email>k@wooster.(none)</email>
  </author>
  <url>http://github.com/mongodb/mongo-perl-driver/commit/5def552e5bfcaa7416c37f83d7fcb3547f10eec0</url>
  <id>5def552e5bfcaa7416c37f83d7fcb3547f10eec0</id>
  <committed-date>2009-10-28T11:10:19-07:00</committed-date>
  <authored-date>2009-10-28T11:10:19-07:00</authored-date>
  <message>fixed binary type 2 MINOR</message>
  <tree>af0cdc05325bb2f0601cfbb7a0520f9a87113806</tree>
  <committer>
    <name>kristina</name>
    <email>k@wooster.(none)</email>
  </committer>
</commit>
