#24
authoradam <adamansky@gmail.com>
Wed, 19 Jun 2013 17:57:22 +0000 (00:57 +0700)
committeradam <adamansky@gmail.com>
Wed, 19 Jun 2013 17:57:22 +0000 (00:57 +0700)
12 files changed:
nejdb/Ejdb.BSON/BSONArray.cs
nejdb/Ejdb.BSON/BSONDocument.cs
nejdb/Ejdb.BSON/BSONRegexp.cs
nejdb/Ejdb.BSON/BSONUndefined.cs [new file with mode: 0644]
nejdb/Ejdb.BSON/BSONull.cs [new file with mode: 0644]
nejdb/Ejdb.DB/EJDB.cs
nejdb/Ejdb.DB/EJDBQCursor.cs
nejdb/Ejdb.DB/EJDBQuery.cs
nejdb/Ejdb.Tests/TestEJDB.cs
nejdb/nejdb.csproj
nejdb/nejdb.userprefs
tcejdb/bson.c

index f03f63d..b45ab02 100644 (file)
@@ -14,6 +14,7 @@
 //   Boston, MA 02111-1307 USA.
 // ============================================================================================
 using System;
+using System.IO;
 
 namespace Ejdb.BSON {
 
@@ -32,6 +33,129 @@ namespace Ejdb.BSON {
                        }
                }
 
+               public BSONArray() {
+               }
+
+               public BSONArray(BSONUndefined[] arr) {
+                       for (var i = 0; i < arr.Length; ++i) {
+                               SetUndefined(i);
+                       }
+               }
+
+               public BSONArray(BSONull[] arr) {
+                       for (var i = 0; i < arr.Length; ++i) {
+                               SetNull(i);
+                       }
+               }
+
+               public BSONArray(ushort[] arr) {
+                       for (var i = 0; i < arr.Length; ++i) {
+                               SetNumber(i, (int) arr[i]);
+                       }
+               }
+
+               public BSONArray(uint[] arr) {
+                       for (var i = 0; i < arr.Length; ++i) {
+                               SetNumber(i, (long) arr[i]);
+                       }
+               }
+
+               public BSONArray(ulong[] arr) {
+                       for (var i = 0; i < arr.Length; ++i) {
+                               SetNumber(i, (long) arr[i]);
+                       }
+               }
+
+               public BSONArray(short[] arr) {
+                       for (var i = 0; i < arr.Length; ++i) {
+                               SetNumber(i, (int) arr[i]);
+                       }
+               }
+
+               public BSONArray(string[] arr) {
+                       for (var i = 0; i < arr.Length; ++i) {
+                               SetString(i, arr[i]);
+                       }
+               }
+
+               public BSONArray(int[] arr) {
+                       for (var i = 0; i < arr.Length; ++i) {
+                               SetNumber(i, arr[i]);
+                       }
+               }
+
+               public BSONArray(long[] arr) {
+                       for (var i = 0; i < arr.Length; ++i) {
+                               SetNumber(i, arr[i]);
+                       }
+               }
+
+               public BSONArray(float[] arr) {
+                       for (var i = 0; i < arr.Length; ++i) {
+                               SetNumber(i, arr[i]);
+                       }
+               }
+
+               public BSONArray(double[] arr) {
+                       for (var i = 0; i < arr.Length; ++i) {
+                               SetNumber(i, arr[i]);
+                       }
+               }
+
+               public BSONArray(bool[] arr) {
+                       for (var i = 0; i < arr.Length; ++i) {
+                               SetBool(i, arr[i]);
+                       }
+               }
+
+               public BSONArray(BSONOid[] arr) {
+                       for (var i = 0; i < arr.Length; ++i) {
+                               SetOID(i, arr[i]);
+                       }
+               }
+
+               public BSONArray(DateTime[] arr) {
+                       for (var i = 0; i < arr.Length; ++i) {
+                               SetDate(i, arr[i]);
+                       }
+               }
+
+               public BSONArray(BSONDocument[] arr) {
+                       for (var i = 0; i < arr.Length; ++i) {
+                               SetObject(i, arr[i]);
+                       }
+               }
+
+               public BSONArray(BSONArray[] arr) {
+                       for (var i = 0; i < arr.Length; ++i) {
+                               SetArray(i, arr[i]);
+                       }
+               }
+
+               public BSONArray(BSONRegexp[] arr) {
+                       for (var i = 0; i < arr.Length; ++i) {
+                               SetRegexp(i, arr[i]);
+                       }
+               }
+
+               public BSONArray(BSONTimestamp[] arr) {
+                       for (var i = 0; i < arr.Length; ++i) {
+                               SetTimestamp(i, arr[i]);
+                       }
+               }
+
+               public BSONArray(BSONCodeWScope[] arr) {
+                       for (var i = 0; i < arr.Length; ++i) {
+                               SetCodeWScope(i, arr[i]);
+                       }
+               }
+
+               public BSONArray(BSONBinData[] arr) {
+                       for (var i = 0; i < arr.Length; ++i) {
+                               SetBinData(i, arr[i]);
+                       }
+               }
+
                public BSONDocument SetNull(int idx) {
                        return base.SetNull(idx.ToString());
                }
index a4b3406..249ad1c 100644 (file)
@@ -34,26 +34,49 @@ namespace Ejdb.BSON {
                static Dictionary<Type, Action<BSONDocument, string, object>> TYPE_SETTERS = 
                new Dictionary<Type, Action<BSONDocument, string, object>> {
                        {typeof(bool), (d, k, v) => d.SetBool(k, (bool) v)},
+                       {typeof(bool[]), (d, k, v) => d.SetArray(k, new BSONArray((bool[]) v))},
                        {typeof(byte), (d, k, v) => d.SetNumber(k, (int) v)},
                        {typeof(sbyte), (d, k, v) => d.SetNumber(k, (int) v)},
                        {typeof(ushort), (d, k, v) => d.SetNumber(k, (int) v)},
+                       {typeof(ushort[]), (d, k, v) => d.SetArray(k, new BSONArray((ushort[]) v))},
                        {typeof(short), (d, k, v) => d.SetNumber(k, (int) v)},
+                       {typeof(short[]), (d, k, v) => d.SetArray(k, new BSONArray((short[]) v))},
                        {typeof(uint), (d, k, v) => d.SetNumber(k, (int) v)},
+                       {typeof(uint[]), (d, k, v) => d.SetArray(k, new BSONArray((uint[]) v))},
                        {typeof(int), (d, k, v) => d.SetNumber(k, (int) v)},
+                       {typeof(int[]), (d, k, v) => d.SetArray(k, new BSONArray((int[]) v))},
                        {typeof(ulong), (d, k, v) => d.SetNumber(k, (long) v)},
+                       {typeof(ulong[]), (d, k, v) => d.SetArray(k, new BSONArray((ulong[]) v))},
                        {typeof(long), (d, k, v) => d.SetNumber(k, (long) v)},
+                       {typeof(long[]), (d, k, v) => d.SetArray(k, new BSONArray((long[]) v))},
                        {typeof(float), (d, k, v) => d.SetNumber(k, (float) v)},
+                       {typeof(float[]), (d, k, v) => d.SetArray(k, new BSONArray((float[]) v))},
                        {typeof(double), (d, k, v) => d.SetNumber(k, (double) v)},
+                       {typeof(double[]), (d, k, v) => d.SetArray(k, new BSONArray((double[]) v))},
                        {typeof(char), (d, k, v) => d.SetString(k, v.ToString())},
                        {typeof(string), (d, k, v) => d.SetString(k, (string) v)},
+                       {typeof(string[]), (d, k, v) => d.SetArray(k, new BSONArray((string[]) v))},
                        {typeof(BSONOid), (d, k, v) => d.SetOID(k, (BSONOid) v)},
+                       {typeof(BSONOid[]), (d, k, v) => d.SetArray(k, new BSONArray((BSONOid[]) v))},
                        {typeof(BSONRegexp), (d, k, v) => d.SetRegexp(k, (BSONRegexp) v)},
+                       {typeof(BSONRegexp[]), (d, k, v) => d.SetArray(k, new BSONArray((BSONRegexp[]) v))},
                        {typeof(BSONValue), (d, k, v) => d.SetBSONValue((BSONValue) v)},
                        {typeof(BSONTimestamp), (d, k, v) => d.SetTimestamp(k, (BSONTimestamp) v)},
+                       {typeof(BSONTimestamp[]), (d, k, v) => d.SetArray(k, new BSONArray((BSONTimestamp[]) v))},
                        {typeof(BSONCodeWScope), (d, k, v) => d.SetCodeWScope(k, (BSONCodeWScope) v)},
+                       {typeof(BSONCodeWScope[]), (d, k, v) => d.SetArray(k, new BSONArray((BSONCodeWScope[]) v))},
                        {typeof(BSONBinData), (d, k, v) => d.SetBinData(k, (BSONBinData) v)},
+                       {typeof(BSONBinData[]), (d, k, v) => d.SetArray(k, new BSONArray((BSONBinData[]) v))},
                        {typeof(BSONDocument), (d, k, v) => d.SetDocument(k, (BSONDocument) v)},
+                       {typeof(BSONDocument[]), (d, k, v) => d.SetArray(k, new BSONArray((BSONDocument[]) v))},
                        {typeof(BSONArray), (d, k, v) => d.SetArray(k, (BSONArray) v)},
+                       {typeof(BSONArray[]), (d, k, v) => d.SetArray(k, new BSONArray((BSONArray[]) v))},
+                       {typeof(DateTime), (d, k, v) => d.SetDate(k, (DateTime) v)},
+                       {typeof(DateTime[]), (d, k, v) => d.SetArray(k, new BSONArray((DateTime[]) v))},
+                       {typeof(BSONUndefined), (d, k, v) => d.SetUndefined(k)},
+                       {typeof(BSONUndefined[]), (d, k, v) => d.SetArray(k, new BSONArray((BSONUndefined[]) v))},
+                       {typeof(BSONull), (d, k, v) => d.SetNull(k)},
+                       {typeof(BSONull[]), (d, k, v) => d.SetArray(k, new BSONArray((BSONull[]) v))}
                };
 
                readonly List<BSONValue> _fieldslist;
@@ -72,7 +95,7 @@ namespace Ejdb.BSON {
                /// </remarks>
                /// <value>The type of the BSON.</value>
                public virtual BSONType BSONType {
-                       get {
+                       get { 
                                return BSONType.OBJECT;
                        }
                }
@@ -527,7 +550,7 @@ namespace Ejdb.BSON {
                                case BSONType.DATE:
                                        {       
                                                DateTime dt = (DateTime) bv.Value;
-                                               var diff = dt.ToUniversalTime() - BSONConstants.Epoch;
+                                               var diff = dt.ToLocalTime() - BSONConstants.Epoch;
                                                long time = (long) Math.Floor(diff.TotalMilliseconds);
                                                WriteTypeAndKey(bv, bw);
                                                bw.Write(time);
index a66cafb..9ec6c8b 100644 (file)
@@ -24,6 +24,7 @@ namespace Ejdb.BSON {
        public sealed class BSONRegexp : IBSONValue {
 
                readonly string _re;
+
                readonly string _opts;
 
                public BSONType BSONType {
@@ -47,6 +48,9 @@ namespace Ejdb.BSON {
                BSONRegexp() {
                }
 
+               public BSONRegexp(string re) : this(re, "") {
+               }
+
                public BSONRegexp(string re, string opts) {
                        this._re = re;
                        this._opts = opts;
diff --git a/nejdb/Ejdb.BSON/BSONUndefined.cs b/nejdb/Ejdb.BSON/BSONUndefined.cs
new file mode 100644 (file)
index 0000000..2ea8e3a
--- /dev/null
@@ -0,0 +1,52 @@
+// ============================================================================================
+//   .NET API for EJDB database library http://ejdb.org
+//   Copyright (C) 2012-2013 Softmotions Ltd <info@softmotions.com>
+//
+//   This file is part of EJDB.
+//   EJDB is free software; you can redistribute it and/or modify it under the terms of
+//   the GNU Lesser General Public License as published by the Free Software Foundation; either
+//   version 2.1 of the License or any later version.  EJDB is distributed in the hope
+//   that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+//   License for more details.
+//   You should have received a copy of the GNU Lesser General Public License along with EJDB;
+//   if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+//   Boston, MA 02111-1307 USA.
+// ============================================================================================
+using System;
+
+namespace Ejdb.BSON {
+
+       public sealed class BSONUndefined : IBSONValue {
+
+               public static BSONUndefined VALUE = new BSONUndefined();
+
+               public BSONType BSONType {
+                       get {
+                               return BSONType.UNDEFINED;
+                       }
+               }
+
+               public override bool Equals(object obj) {
+                       if (obj == null) {
+                               return false;
+                       }
+                       if (ReferenceEquals(this, obj)) {
+                               return true;
+                       }
+                       if (!(obj is BSONUndefined)) {
+                               return false;
+                       }
+                       return true;
+               }
+
+               public override int GetHashCode() {
+                       return 0;
+               }
+
+               public override string ToString() {
+                       return "[BSONUndefined]";
+               }
+       }
+}
+
diff --git a/nejdb/Ejdb.BSON/BSONull.cs b/nejdb/Ejdb.BSON/BSONull.cs
new file mode 100644 (file)
index 0000000..2e74028
--- /dev/null
@@ -0,0 +1,53 @@
+// ============================================================================================
+//   .NET API for EJDB database library http://ejdb.org
+//   Copyright (C) 2012-2013 Softmotions Ltd <info@softmotions.com>
+//
+//   This file is part of EJDB.
+//   EJDB is free software; you can redistribute it and/or modify it under the terms of
+//   the GNU Lesser General Public License as published by the Free Software Foundation; either
+//   version 2.1 of the License or any later version.  EJDB is distributed in the hope
+//   that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+//   License for more details.
+//   You should have received a copy of the GNU Lesser General Public License along with EJDB;
+//   if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+//   Boston, MA 02111-1307 USA.
+// ============================================================================================
+using System;
+
+namespace Ejdb.BSON {
+
+       [Serializable]
+       public sealed class BSONull : IBSONValue {
+
+               public static BSONull VALUE = new BSONull();
+
+               public BSONType BSONType {
+                       get {
+                               return BSONType.NULL;
+                       }
+               }
+
+               public override bool Equals(object obj) {
+                       if (obj == null) {
+                               return false;
+                       }
+                       if (ReferenceEquals(this, obj)) {
+                               return true;
+                       }
+                       if (!(obj is BSONull)) {
+                               return false;
+                       }
+                       return true;
+               }
+
+               public override int GetHashCode() {
+                       return 0;
+               }
+
+               public override string ToString() {
+                       return "[BSONull]";
+               }
+       }
+}
+
index b9ff2d5..94cbf50 100644 (file)
@@ -211,21 +211,48 @@ namespace Ejdb.DB {
                }
 
                /// <summary>
-               /// Save the BSON document doc into the collection cname.
+               /// Save the BSON document doc into the collection.
                /// </summary>
                /// <param name="cname">Name of collection.</param>
-               /// <param name="doc">BSON document to save.</param>
-               /// <param name="merge">If set to <c>true</c> 
-               /// If true the merge will be performend with old and new objects. 
-               /// Otherwise old object will be replaced.</param>
+               /// <param name="docs">BSON documents to save.</param>
                /// <returns>True on success.</returns>
-               public bool Save(string cname, BSONDocument doc, bool merge = false) {
+               public bool Save(string cname, params BSONDocument[] docs) {
+                       CheckDisposed();
+                       IntPtr cptr = _ejdbcreatecoll(_db, cname, null);
+                       if (cptr == IntPtr.Zero) {
+                               return false;
+                       }
+                       foreach (var doc in docs) {
+                               if (!Save(cptr, doc, false)) {
+                                       return false;
+                               }
+                       }
+                       return true;
+               }
+
+               /// <summary>
+               /// Save the BSON document doc into the collection.
+               /// And merge each doc object identified by <c>_id</c> with doc stored in DB.
+               /// </summary>
+               /// <param name="cname">Name of collection.</param>
+               /// <param name="docs">BSON documents to save.</param>
+               /// <returns>True on success.</returns>
+               public bool SaveMerge(string cname, params BSONDocument[] docs) {
                        CheckDisposed();
-                       bool rv;
                        IntPtr cptr = _ejdbcreatecoll(_db, cname, null);
                        if (cptr == IntPtr.Zero) {
                                return false;
                        }
+                       foreach (var doc in docs) {
+                               if (!Save(cptr, doc, true)) {
+                                       return false;
+                               }
+                       }
+                       return true;
+               }
+
+               bool Save(IntPtr cptr, BSONDocument doc, bool merge) {
+                       bool rv;
                        BSONValue bv = doc.GetBSONValue("_id");
                        byte[] bsdata = doc.ToByteArray();
                        byte[] oiddata = new byte[12];
@@ -265,9 +292,14 @@ namespace Ejdb.DB {
                /// <returns>The query object.</returns>
                /// <param name="qdoc">BSON query spec.</param>
                /// <param name="defaultcollection">Name of the collection used by default.</param>
-               public EJDBQuery CreateQuery(BSONDocument qdoc, string defaultcollection = null) {
+               public EJDBQuery CreateQuery(object qv = null, string defaultcollection = null) {
+                       CheckDisposed();
+                       return new EJDBQuery(this, BSONDocument.ValueOf(qv), defaultcollection);
+               }
+
+               public EJDBQuery CreateQueryFor(string defaultcollection) {
                        CheckDisposed();
-                       return new EJDBQuery(this, qdoc, defaultcollection);
+                       return new EJDBQuery(this, new BSONDocument(), defaultcollection);
                }
                //.//////////////////////////////////////////////////////////////////
                //                                               Private staff                                                     //     
index 4d037f3..3596fe1 100644 (file)
@@ -66,20 +66,28 @@ namespace Ejdb.DB {
                        _len = len;
                }
 
+               public BSONIterator this[int idx] {
+                       get {
+                               if (_qresptr == IntPtr.Zero || idx >= _len || idx < 0) {
+                                       return null;
+                               }
+                               //static extern IntPtr _ejdbqresultbsondata([In] IntPtr qres, [In] int idx, out int size)
+                               int size;
+                               IntPtr bsdataptr = _ejdbqresultbsondata(_qresptr, idx, out size);
+                               if (bsdataptr == IntPtr.Zero) {
+                                       return null;
+                               }
+                               byte[] bsdata = new byte[size];
+                               Marshal.Copy(bsdataptr, bsdata, 0, bsdata.Length);
+                               return new BSONIterator(bsdata);
+                       }
+               }
+
                public BSONIterator Next() {
                        if (_qresptr == IntPtr.Zero || _pos >= _len) {
                                return null;
                        }
-                       //static extern IntPtr _ejdbqresultbsondata([In] IntPtr qres, [In] int idx, out int size)
-                       int size;
-                       IntPtr bsdataptr = _ejdbqresultbsondata(_qresptr, _pos, out size);
-                       if (bsdataptr == IntPtr.Zero) {
-                               return null;
-                       }
-                       byte[] bsdata = new byte[size];
-                       Marshal.Copy(bsdataptr, bsdata, 0, bsdata.Length);
-                       _pos++;
-                       return new BSONIterator(bsdata);
+                       return this[_pos++];
                }
 
                public IEnumerator<BSONIterator> GetEnumerator() {
index 24d70ad..16415bb 100644 (file)
@@ -105,6 +105,9 @@ namespace Ejdb.DB {
                        get {
                                return _defaultcollection;
                        }
+                       set {
+                               _defaultcollection = value;
+                       }
                }
 
                internal EJDBQuery(EJDB jb, BSONDocument qdoc, string defaultcollection = null) {
@@ -277,6 +280,11 @@ namespace Ejdb.DB {
                        }
                        _hints = null;
                }
+
+               public EJDBQuery SetDefaultCollection(string cname) {
+                       _defaultcollection = cname;
+                       return this;
+               }
                //.//////////////////////////////////////////////////////////////////
                //                                              Privates                                                                   //                                                                     
                //.//////////////////////////////////////////////////////////////////
index 4fc56bd..0b11d37 100644 (file)
@@ -100,12 +100,59 @@ namespace Ejdb.Tests {
                        }
                        q.Max(10);
                        using (EJDBQCursor cursor = q.Find(null, EJDBQuery.EXPLAIN_FLAG)) {
-                               Console.WriteLine(cursor.Log);
+                               Assert.IsTrue(cursor.Log.IndexOf("MAX: 10") != -1);
                        }
 
                        q.Dispose();
                        jb.Dispose(); 
                }
+
+               [Test]
+               public void Test4Q2() {
+                       EJDB jb = new EJDB("testdb1", EJDB.DEFAULT_OPEN_MODE | EJDB.JBOTRUNC);
+                       Assert.IsTrue(jb.IsOpen);
+
+                       var parrot1 = BSONDocument.ValueOf(new{
+                               name = "Grenny",
+                               type = "African Grey",
+                               male = true, 
+                               age = 1,
+                               birthdate = DateTime.Now,
+                               likes = new string[] { "green color", "night", "toys" },
+                               extra1 = BSONull.VALUE
+                       });
+
+                       var parrot2 = BSONDocument.ValueOf(new{
+                               name = "Bounty",
+                               type = "Cockatoo",
+                               male = false,
+                               age = 15,
+                               birthdate = DateTime.Now,
+                               likes = new string[] { "sugar cane" },
+                               extra1 = BSONull.VALUE
+                       });
+                       Assert.IsTrue(jb.Save("parrots", parrot1, parrot2));
+                       Assert.AreEqual(2, jb.CreateQueryFor("parrots").Count()); 
+
+                       var q = jb.CreateQuery(new{
+                                       name = new BSONRegexp("(grenny|bounty)", "i")
+                       }).SetDefaultCollection("parrots").OrderBy("name");
+
+                       using (var cur = q.Find()) {
+                               Assert.AreEqual(2, cur.Length);
+
+                               var doc = cur[0].ToBSONDocument();
+                               Assert.AreEqual("Bounty", doc["name"]);
+                               Assert.AreEqual(15, doc["age"]);
+
+                               doc = cur[1].ToBSONDocument();
+                               Assert.AreEqual("Grenny", doc["name"]);
+                               Assert.AreEqual(1, doc["age"]);
+                       }
+
+                       q.Dispose();
+                       jb.Dispose();
+               }
        }
 }
 
index 8a7fbdc..715da57 100644 (file)
@@ -67,6 +67,8 @@
     <Compile Include="Ejdb.DB\EJDBQuery.cs" />
     <Compile Include="Ejdb.DB\EJDBQueryException.cs" />
     <Compile Include="Ejdb.DB\EJDBQCursor.cs" />
+    <Compile Include="Ejdb.BSON\BSONull.cs" />
+    <Compile Include="Ejdb.BSON\BSONUndefined.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <ItemGroup>
index 2e44254..9f80e0d 100644 (file)
@@ -2,12 +2,13 @@
   <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
   <MonoDevelop.Ide.Workbench ActiveDocument="Ejdb.Tests/TestEJDB.cs">
     <Files>
-      <File FileName="Ejdb.DB/EJDB.cs" Line="275" Column="3" />
-      <File FileName="Ejdb.BSON/BSONIterator.cs" Line="25" Column="2" />
-      <File FileName="Ejdb.DB/EJDBQuery.cs" Line="196" Column="21" />
-      <File FileName="Ejdb.DB/EJDBQCursor.cs" Line="26" Column="66" />
-      <File FileName="Ejdb.BSON/BSONDocument.cs" Line="144" Column="3" />
-      <File FileName="Ejdb.Tests/TestEJDB.cs" Line="24" Column="23" />
+      <File FileName="Ejdb.DB/EJDB.cs" Line="295" Column="16" />
+      <File FileName="Ejdb.DB/EJDBQuery.cs" Line="286" Column="16" />
+      <File FileName="Ejdb.DB/EJDBQCursor.cs" Line="71" Column="60" />
+      <File FileName="Ejdb.BSON/BSONDocument.cs" Line="224" Column="35" />
+      <File FileName="Ejdb.Tests/TestEJDB.cs" Line="112" Column="4" />
+      <File FileName="Ejdb.BSON/BSONRegexp.cs" Line="53" Column="3" />
+      <File FileName="Ejdb.BSON/BSONIterator.cs" Line="133" Column="20" />
     </Files>
     <Pads>
       <Pad Id="ProjectPad">
         <State selected="True" />
       </Pad>
       <Pad Id="MonoDevelop.NUnit.TestPad">
-        <State expanded="True">
+        <State expanded="True" selected="True">
           <Node name="nejdb" expanded="True">
             <Node name="Ejdb" expanded="True">
               <Node name="Tests" expanded="True">
-                <Node name="TestEJDB" expanded="True">
-                  <Node name="Test4Q1" selected="True" />
-                </Node>
+                <Node name="TestEJDB" expanded="True" />
               </Node>
             </Node>
           </Node>
@@ -53,9 +52,7 @@
     </Pads>
   </MonoDevelop.Ide.Workbench>
   <MonoDevelop.Ide.DebuggingService.Breakpoints>
-    <BreakpointStore>
-      <Breakpoint file="/home/adam/Projects/softmotions/ejdb/nejdb/Ejdb.Tests/TestEJDB.cs" line="101" column="8" />
-    </BreakpointStore>
+    <BreakpointStore />
   </MonoDevelop.Ide.DebuggingService.Breakpoints>
   <MonoDevelop.Ide.DebuggingService.PinnedWatches />
 </Properties>
\ No newline at end of file
index 1ab323e..7a7a5c5 100644 (file)
@@ -1660,6 +1660,7 @@ bson* bson_create_from_iterator(bson_iterator *from) {
     assert(from);
     bson_type bt;
     bson *bs = bson_create();
+    bson_init_as_query(bs);
     while ((bt = bson_iterator_next(from)) != BSON_EOO) {
         bson_append_field_from_iterator(from, bs);
     }