Permalink
Browse files

Merge branch 'master' of https://github.com/ayende/ravendb

  • Loading branch information...
2 parents 4fa5090 + 62a489b commit e9f07d5bf33de427a1150dbd4122c130ac01e1a1 @fitzchak fitzchak committed Nov 21, 2011
Showing with 680 additions and 119 deletions.
  1. +1 −2 .gitignore
  2. +1 −0 Bundles/Raven.Bundles.Tests/Raven.Bundles.Tests.csproj
  3. +45 −0 Bundles/Raven.Bundles.Tests/Versioning/Bugs/MultipleVersions.cs
  4. +0 −1 Bundles/Raven.Bundles.Tests/Versioning/Versioning.cs
  5. +6 −4 Raven.Abstractions/Data/ConnectionStringParser.cs
  6. +13 −2 Raven.Abstractions/Json/Linq/RavenJToken.cs
  7. +42 −2 Raven.Abstractions/Json/Linq/RavenJValue.cs
  8. +15 −0 Raven.Abstractions/Linq/DynamicNullObject.cs
  9. +9 −0 Raven.Client.Embedded/EmbeddedDatabaseCommands.cs
  10. +12 −2 Raven.Client.Lightweight/Connection/Async/AsyncServerClient.cs
  11. +1 −1 Raven.Client.Lightweight/Connection/HttpJsonRequest.cs
  12. +6 −0 Raven.Client.Lightweight/Connection/IDatabaseCommands.cs
  13. +99 −0 Raven.Client.Lightweight/Connection/RavenUrlExtensions.cs
  14. +11 −0 Raven.Client.Lightweight/Connection/ServerClient.cs
  15. +1 −0 Raven.Client.Lightweight/Raven.Client.Lightweight.csproj
  16. +1 −1 Raven.Client.Silverlight/Connection/HttpJsonRequest.cs
  17. +1 −2 Raven.Database/DocumentDatabase.cs
  18. +5 −6 Raven.Database/Extensions/HttpExtensions.cs
  19. +5 −2 Raven.Database/Indexing/Index.cs
  20. +5 −4 Raven.Database/Json/JsonPatcher.cs
  21. +65 −65 Raven.Database/Server/Responders/SilverlightUI.cs
  22. +2 −2 Raven.Database/Server/WebUI/js/jquery.RavenDB.js
  23. +4 −5 Raven.Database/Storage/IndexDefinitionStorage.cs
  24. +13 −2 Raven.Studio/Models/EditableDocumentModel.cs
  25. 0 Raven.Studio/Settings.dat
  26. +1 −0 Raven.Tests.Silverlight/AsyncLinqQueryTests.cs
  27. +57 −0 Raven.Tests/MailingList/RavenDbPutTest.cs
  28. +13 −2 Raven.Tests/MailingList/{ → spokeypokey}/spokeypokey.cs
  29. +1 −1 Raven.Tests/MailingList/{ → spokeypokey}/spokeypokey2.cs
  30. +155 −0 Raven.Tests/MailingList/spokeypokey/spokeypokey3.cs
  31. +4 −2 Raven.Tests/Raven.Tests.csproj
  32. +1 −0 Raven.Tests/RavenTest.cs
  33. +28 −0 Raven.Web/BootStrapper.cs
  34. +30 −10 Raven.Web/ForwardToRavenRespondersFactory.cs
  35. +3 −1 Raven.Web/Raven.Web.csproj
  36. +24 −0 RavenDB.sln
View
@@ -39,6 +39,5 @@ ClientBin/
/Modules/Json/Raven.Json/Raven.Json.g.3.5.csproj
*.docstates
StyleCop.Cache
-/Raven.Studio/Settings.dat
-*.vs10x
+
*.dotCover
@@ -82,6 +82,7 @@
<Compile Include="Replication\ReplicationBase.cs" />
<Compile Include="Replication\SimpleReplication.cs" />
<Compile Include="Replication\WritesDuringFailover.cs" />
+ <Compile Include="Versioning\Bugs\MultipleVersions.cs" />
<Compile Include="Versioning\Bugs\VersioningWithGuidIds.cs" />
<Compile Include="Versioning\Versioning.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -0,0 +1,45 @@
+using Raven.Bundles.Versioning.Data;
+using Xunit;
+using Raven.Client.Versioning;
+
+namespace Raven.Bundles.Tests.Versioning.Bugs
+{
+ public class MultipleVersions : VersioningTest
+ {
+
+ [Fact]
+ public void Will_automatically_set_metadata()
+ {
+ using(var s = documentStore.OpenSession())
+ {
+ s.Store(new VersioningConfiguration
+ {
+ Exclude = false,
+ Id = "Raven/Versioning/DefaultConfiguration",
+ MaxRevisions = 50
+ });
+ s.SaveChanges();
+ }
+
+ for (int i = 0; i < 10; i++)
+ {
+ using (var session = documentStore.OpenSession())
+ {
+ session.Store(new Company
+ {
+ Name = "Company " + i,
+ Id = "companies/1"
+ });
+ session.SaveChanges();
+ }
+ }
+
+ using (var session = documentStore.OpenSession())
+ {
+ var company = session.Load<Company>("companies/1");
+ var companies = session.Advanced.GetRevisionsFor<Company>(company.Id, 0, 15);
+ Assert.Equal(10, companies.Length);
+ }
+ }
+ }
+}
@@ -212,7 +212,6 @@ public class User
public class Company
{
public string Name { get; set; }
-
public string Id { get; set; }
}
}
@@ -82,7 +82,7 @@ private ConnectionStringParser(string connectionStringName, string connectionStr
/// <summary>
/// Parse the connection string option
/// </summary>
- protected virtual void ProcessConnectionStringOption(NetworkCredential neworkCredentials, string key, string value)
+ protected virtual void ProcessConnectionStringOption(NetworkCredential networkCredentials, string key, string value)
{
var embeddedRavenConnectionStringOptions = ConnectionStringOptions as EmbeddedRavenConnectionStringOptions;
switch (key)
@@ -118,14 +118,16 @@ protected virtual void ProcessConnectionStringOption(NetworkCredential neworkCre
ConnectionStringOptions.DefaultDatabase = value;
break;
case "user":
- neworkCredentials.UserName = value;
+ networkCredentials.UserName = value;
setupUsernameInConnectionString = true;
break;
case "password":
- neworkCredentials.Password = value;
+ networkCredentials.Password = value;
setupPasswordInConnectionString = true;
break;
-
+ case "domain":
+ networkCredentials.Domain = value;
+ break;
default:
throw new ArgumentException(string.Format("Connection string name: '{0}' could not be parsed, unknown option: '{1}'", connectionStringName, key));
}
@@ -263,8 +263,19 @@ internal virtual bool DeepEquals(RavenJToken other)
RavenJToken token;
if (otherObj.TryGetValue(kvp.Key, out token) == false)
return false;
- otherStack.Push(token);
- thisStack.Push(kvp.Value);
+ switch (kvp.Value.Type)
+ {
+ case JTokenType.Array:
+ case JTokenType.Object:
+ otherStack.Push(token);
+ thisStack.Push(kvp.Value);
+ break;
+ default:
+ if (!kvp.Value.DeepEquals(token))
+ return false;
+ break;
+ }
+
}
}
else // value
@@ -361,7 +361,38 @@ public bool Equals(RavenJValue other)
private static bool ValuesEquals(RavenJValue v1, RavenJValue v2)
{
- return (v1 == v2 || (v1._valueType == v2._valueType && Compare(v1._valueType, v1._value, v2._value) == 0));
+ if(v1 == v2 )
+ return true;
+
+ switch (v1._valueType)
+ {
+ case JTokenType.Guid:
+ switch (v2._valueType)
+ {
+ case JTokenType.String:
+ case JTokenType.Guid:
+ break;
+ default:
+ return false;
+ }
+ break;
+ case JTokenType.String:
+ switch (v2._valueType)
+ {
+ case JTokenType.String:
+ case JTokenType.Guid:
+ break;
+ default:
+ return false;
+ }
+ break;
+ default:
+ if (v1._valueType != v2._valueType)
+ return false;
+ break;
+ }
+
+ return Compare(v1._valueType, v1._value, v2._value) == 0;
}
public int CompareTo(RavenJValue other)
@@ -433,7 +464,16 @@ private static int Compare(JTokenType valueType, object objA, object objB)
return MiscellaneousUtils.ByteArrayCompare(bytes1, bytes2);
case JTokenType.Guid:
if (!(objB is Guid))
- throw new ArgumentException("Object must be of type Guid.");
+ {
+#if !NET_3_5
+ Guid guid;
+ if(Guid.TryParse((string) objB, out guid) == false)
+ throw new ArgumentException("Object must be of type Guid.");
+ objB = guid;
+#else
+ objB = new Guid((string)objB);
+#endif
+ }
Guid guid1 = (Guid)objA;
Guid guid2 = (Guid)objB;
@@ -32,6 +32,21 @@ public IEnumerator<object> GetEnumerator()
yield break;
}
+ public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
+ {
+ switch (binder.Name)
+ {
+ case "Count":
+ result = 0;
+ return true;
+ case "DefaultIfEmpty":
+ result = new[]{this};
+ return true;
+ default:
+ return base.TryInvokeMember(binder, args, out result);
+ }
+ }
+
public override bool TryInvoke(InvokeBinder binder, object[] args, out object result)
{
result = this;
@@ -184,6 +184,15 @@ public void DeleteAttachment(string key, Guid? etag)
}
/// <summary>
+ /// Get tenant database names (Server/Client mode only)
+ /// </summary>
+ /// <returns></returns>
+ public string[] GetDatabaseNames()
+ {
+ throw new InvalidOperationException("Embedded mode does not support multi-tenancy");
+ }
+
+ /// <summary>
/// Gets the index names from the server
/// </summary>
/// <param name="start">Paging start</param>
@@ -39,7 +39,7 @@ public class AsyncServerClient : IAsyncDatabaseCommands
private readonly ICredentials credentials;
private readonly DocumentConvention convention;
private readonly IDictionary<string, string> operationsHeaders = new Dictionary<string, string>();
- private readonly HttpJsonRequestFactory jsonRequestFactory;
+ internal readonly HttpJsonRequestFactory jsonRequestFactory;
private readonly Guid? sessionId;
/// <summary>
@@ -615,7 +615,17 @@ public Task<DatabaseStatistics> GetStatisticsAsync()
/// </summary>
public Task<string[]> GetDatabaseNamesAsync()
{
- throw new NotImplementedException();
+ return url.Databases()
+ .NoCache()
+ .ToJsonRequest(this, credentials, convention)
+ .ReadResponseStringAsync()
+ .ContinueWith(task =>
+ {
+ var json = (RavenJArray)RavenJToken.Parse(task.Result);
+ return json
+ .Select(x => x.Value<RavenJObject>("@metadata").Value<string>("@id").Replace("Raven/Databases/", string.Empty))
+ .ToArray();
+ });
}
/// <summary>
@@ -359,7 +359,7 @@ private void WriteMetadata(RavenJObject metadata)
var headerName = prop.Key;
if (headerName == "ETag")
- headerName = "If-Match";
+ headerName = "If-None-Match";
var value = prop.Value.Value<object>().ToString();
// Restricted headers require their own special treatment, otherwise an exception will
@@ -89,6 +89,12 @@ public interface IDatabaseCommands : IHoldProfilingInformation
void DeleteAttachment(string key, Guid? etag);
/// <summary>
+ /// Returns the names of all tenant databases on the RavenDB server
+ /// </summary>
+ /// <returns>List of tenant database names</returns>
+ string[] GetDatabaseNames();
+
+ /// <summary>
/// Returns the names of all indexes that exist on the server
/// </summary>
/// <param name="start">Paging start</param>
@@ -0,0 +1,99 @@
+using System;
+using System.Collections.Generic;
+using System.Net;
+#if !NET_3_5
+using Raven.Client.Connection.Async;
+#endif
+using Raven.Client.Document;
+
+namespace Raven.Client.Connection
+{
+ public static class RavenUrlExtensions
+ {
+ public static string Indexes(this string url, string index)
+ {
+ return url + "/indexes/" + index;
+ }
+
+ public static string IndexDefinition(this string url, string index)
+ {
+ return url + "/indexes/" + index + "?definition=yes";
+ }
+
+ public static string IndexNames(this string url, int start, int pageSize)
+ {
+ return url + "/indexes/?namesOnly=true&start=" + start + "&pageSize=" + pageSize;
+ }
+
+ public static string Stats(this string url)
+ {
+ return url + "/stats";
+ }
+
+ //public static string Static(this string url, string key)
+ //{
+ // return url + "/static/" + HttpUtility.HtmlEncode(key);
+ //}
+
+ public static string Databases(this string url)
+ {
+ return url + "/databases/";
+ }
+
+ public static string SilverlightEnsuresStartup(this string url)
+ {
+ return url + "/silverlight/ensureStartup";
+ }
+
+ public static string Terms(this string url, string index, string field, string fromValue, int pageSize)
+ {
+ return url + "/terms/" + index + "?field=" + field + "&fromValue=" + fromValue + "&pageSize=" + pageSize;
+ }
+
+ //public static string Docs(this string url, string key)
+ //{
+ // return url + "/docs/" + HttpUtility.HtmlEncode(key);
+ //}
+
+ public static string Docs(this string url, int start, int pageSize)
+ {
+ return url + "/docs/?start=" + start + "&pageSize=" + pageSize;
+ }
+
+ //public static string DocsStartingWith(this string url, string prefix, int start, int pageSize)
+ //{
+ // return Docs(url, start, pageSize) + "&startsWith=" + HttpUtility.HtmlEncode(prefix);
+ //}
+
+ public static string Queries(this string url)
+ {
+ return url + "/queries/";
+ }
+
+ public static string NoCache(this string url)
+ {
+ return (url.Contains("?"))
+ ? url + "&noCache=" + Guid.NewGuid().GetHashCode()
+ : url + "?noCache=" + Guid.NewGuid().GetHashCode();
+ }
+
+ public static Uri ToUri(this string url)
+ {
+ return new Uri(url);
+ }
+
+#if !NET_3_5
+ public static HttpJsonRequest ToJsonRequest(this string url, AsyncServerClient requestor, ICredentials credentials, Document.DocumentConvention convention)
+ {
+ return requestor.jsonRequestFactory.CreateHttpJsonRequest(requestor, url, "GET", credentials, convention);
+ }
+
+ public static HttpJsonRequest ToJsonRequest(this string url, AsyncServerClient requestor, ICredentials credentials, DocumentConvention convention, IDictionary<string, string> operationsHeaders, string method)
+ {
+ var httpJsonRequest = requestor.jsonRequestFactory.CreateHttpJsonRequest(requestor, url, method, credentials, convention);
+ httpJsonRequest.AddOperationHeaders(operationsHeaders);
+ return httpJsonRequest;
+ }
+#endif
+ }
+}
@@ -477,6 +477,17 @@ public void DeleteAttachment(string key, Guid? etag)
ExecuteWithReplication("DELETE", operationUrl => DirectDeleteAttachment(key, etag, operationUrl));
}
+ public string[] GetDatabaseNames()
+ {
+ var result = ExecuteGetRequest(url.Databases().NoCache());
+
+ var json = (RavenJArray) RavenJToken.Parse(result);
+
+ return json
+ .Select(x => x.Value<RavenJObject>("@metadata").Value<string>("@id").Replace("Raven/Databases/", string.Empty))
+ .ToArray();
+ }
+
private void DirectDeleteAttachment(string key, Guid? etag, string operationUrl)
{
var webRequest = WebRequest.Create(operationUrl + "/static/" + key);
@@ -87,6 +87,7 @@
<Compile Include="Connection\Profiling\ProfilingInformation.cs" />
<Compile Include="Connection\RavenQuery.cs" />
<Compile Include="Connection\RavenTransactionAccessor.cs" />
+ <Compile Include="Connection\RavenUrlExtensions.cs" />
<Compile Include="Connection\ReplicationInformer.cs" />
<Compile Include="Connection\SerializationHelper.cs" />
<Compile Include="Connection\ServerClient.cs" />
Oops, something went wrong.

0 comments on commit e9f07d5

Please sign in to comment.