diff --git a/LiteDB.Shell/Properties/launchSettings.json b/LiteDB.Shell/Properties/launchSettings.json index 7b9a2758e..f70c40282 100644 --- a/LiteDB.Shell/Properties/launchSettings.json +++ b/LiteDB.Shell/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "LiteDB.Shell": { "commandName": "Project", - "commandLineArgs": "C:\\Temp\\app.db" + "commandLineArgs": "bin/Debug/net40/Game.db" } } } \ No newline at end of file diff --git a/LiteDB.Shell/Shell/ShellProgram.cs b/LiteDB.Shell/Shell/ShellProgram.cs index 27abd3481..4b0cb2a6b 100644 --- a/LiteDB.Shell/Shell/ShellProgram.cs +++ b/LiteDB.Shell/Shell/ShellProgram.cs @@ -28,7 +28,7 @@ public static void Start(InputCommand input, Display display) if (string.IsNullOrEmpty(cmd)) continue; - try + //try { var s = new StringScanner(cmd); @@ -51,9 +51,9 @@ public static void Start(InputCommand input, Display display) display.WriteResult(env.Engine.Run(cmd)); } } - catch (Exception ex) + //catch (Exception ex) { - display.WriteError(ex); + //display.WriteError(ex); } } } diff --git a/LiteDB.Tests/Engine/Delete_Query_Tests.cs b/LiteDB.Tests/Engine/Delete_Query_Tests.cs new file mode 100644 index 000000000..b0f217e6a --- /dev/null +++ b/LiteDB.Tests/Engine/Delete_Query_Tests.cs @@ -0,0 +1,45 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +namespace LiteDB.Tests.Engine +{ + [TestClass] + public class Delete_Query_Tests + { + [TestMethod] + public void Delete_Query() + { + using (var file = new TempFile()) + { + var initial = new DateTime(2000, 01, 01); + + using (var db = new LiteEngine(file.Filename)) + { + for(var i = 0; i < 5000; i++) + { + db.Insert("col", new BsonDocument { { "dt", initial.AddDays(i) } }); + } + + db.EnsureIndex("col", "dt"); + + Assert.AreEqual(5000, db.Count("col")); + + Assert.AreEqual(0, db.Count("col", Query.GT("dd", initial))); + + var del = db.Delete("col", Query.GT("dd", initial)); + + Assert.AreEqual(0, del); + + Assert.AreEqual(0, db.Count("col", Query.GT("dd", initial))); + + } + } + } + } +} \ No newline at end of file diff --git a/LiteDB/Document/Expression/Methods/Misc.cs b/LiteDB/Document/Expression/Methods/Misc.cs index 08e4d8f31..02d71cb80 100644 --- a/LiteDB/Document/Expression/Methods/Misc.cs +++ b/LiteDB/Document/Expression/Methods/Misc.cs @@ -33,5 +33,19 @@ public static IEnumerable IIF(IEnumerable condition, IEnum yield return value.First.AsBoolean ? value.Second : value.Third; } } + + /// + /// Return length of variant value (valid only for String, Binary, Array or Document [keys]) + /// + public static IEnumerable LENGTH(IEnumerable values) + { + foreach (var value in values) + { + if (value.IsString) yield return value.AsString.Length; + else if (value.IsBinary) yield return value.AsBinary.Length; + else if (value.IsArray) yield return value.AsArray.Count; + else if (value.IsDocument) yield return value.AsDocument.Keys.Count; + } + } } }