diff --git a/lib/Newtonsoft.Json.dll b/lib/Newtonsoft.Json.dll index 782e9c0..82bdf17 100644 Binary files a/lib/Newtonsoft.Json.dll and b/lib/Newtonsoft.Json.dll differ diff --git a/src/CouchQuery.cs b/src/CouchQuery.cs index ebebed6..97ec530 100644 --- a/src/CouchQuery.cs +++ b/src/CouchQuery.cs @@ -67,7 +67,7 @@ public CouchQuery Keys(IList keys) /// public CouchQuery Key(object value) { - Options["key"] = JToken.FromObject(value).ToString(); + Options["key"] = value == null ? "null" : JToken.FromObject(value).ToString(); return this; } @@ -257,7 +257,16 @@ public CouchRequest Request() } } - JObject json = req.Parse(); + JObject json; + try + { + json = req.Parse(); + } + catch(WebException e) + { + throw CouchException.Create("Query failed", e); + } + if (json != null) // ETag did not match, view has changed { Result.Result(json); diff --git a/src/CouchRequest.cs b/src/CouchRequest.cs index cff19b0..6d2209e 100644 --- a/src/CouchRequest.cs +++ b/src/CouchRequest.cs @@ -21,15 +21,17 @@ public class CouchRequest private Stream postStream; private readonly CouchServer server; private string etag, etagToCheck; - public Dictionary headers = new Dictionary(); + private Dictionary headers = new Dictionary(); // Query options - public string method = "GET"; // PUT, DELETE, POST, HEAD - public string mimeType; - public string path; - public string query; + private string method = "GET"; // PUT, DELETE, POST, HEAD + private string mimeType; + private string path; + private string query; - public JToken result; + private JToken result; + + #region Contructors public CouchRequest(CouchServer server) { @@ -42,6 +44,13 @@ public CouchRequest(CouchDatabase db) this.db = db; } + #endregion + + /// + /// Sets the e-tag value + /// + /// The e-tag value + /// A CouchRequest with the new e-tag value public CouchRequest Etag(string value) { etagToCheck = value; @@ -49,15 +58,25 @@ public CouchRequest Etag(string value) return this; } + /// + /// Sets the absolute path in the query + /// + /// The absolute path + /// A with the new path set. public CouchRequest Path(string name) { path = name; return this; } - public CouchRequest Query(string name) + /// + /// Sets the raw query information in the request. Don't forget to start with a question mark (?). + /// + /// The raw query + /// A with the new query set. + public CouchRequest Query(string value) { - query = name; + query = value; return this; } @@ -251,8 +270,6 @@ public JObject Parse() public T Parse() where T : JToken { - //var timer = new Stopwatch(); - //timer.Start(); using (WebResponse response = GetResponse()) { using (Stream stream = response.GetResponseStream()) @@ -274,8 +291,7 @@ public T Parse() where T : JToken } } } - //timer.Stop(); - //Trace.WriteLine("Time for Couch HTTP & JSON PARSE: " + timer.ElapsedMilliseconds); + return (T)result; } diff --git a/src/Divan.csproj b/src/Divan.csproj index d941d0c..d7490cc 100644 --- a/src/Divan.csproj +++ b/src/Divan.csproj @@ -1,9 +1,9 @@ - + Debug AnyCPU - 9.0.21022 + 9.0.30729 2.0 {37AC0B66-5340-4B81-BC62-3EE80233A011} Library @@ -31,7 +31,7 @@ 3 - + False ..\lib\Newtonsoft.Json.dll