Sorry for getting out the loop, got stuck with something else.
There are very valid scenarios where you want to store an URL in the ID field, just consider the case where I'm trying to store OpenId claimed Id's in my database and I want to enforce uniqueness among them (so no Id gets associated with multiple accounts). I'd therefore MUST store the OpenId URLs as ID for RavenDb because there's no other way to guarantee uniquess if not with an ID index (thats what the docs say).
I tried encoded as well as unencoded URls, but both fail. What's _really_ problematic is the fact that its not only the Studio but also RavenDb client that fails - but only when used over http. When I ran the tests with the InMemoryStore I did not detect these errors. Here's a Repro, which requires running against an HTTP DocumentStore:
public class Repro
{
public class Login
{
public const string DocumentTypePrefix = "logins/";
public string Id { get; private set; }
private Login() {}
public static Login Create( string claimedId )
{
// Both of these variants fail, make sure to clear the database before running this test though!
//string encodedIdentifier = System.Web.HttpUtility.UrlEncode( claimedId );
string encodedIdentifier = claimedId;
return new Login()
{
Id = Login.DocumentTypePrefix + encodedIdentifier
};
}
}
[Fact]
public void CanSaveAndRetrieveTestOpenId()
{
store.Initialize();
string id = default( string );
using (var session = store.OpenSession())
{
session.Store( login );
session.SaveChanges();
id = login.Id;
}
using (var session = store.OpenSession())
{
var doc = session.Load<Login>( id );
Assert.NotNull( doc );
}
}
}
Since I can't store URLs as Ids (either encoded or unencoded), the question now is how to properly store my OpenIds and still get a proper uniqueness constraint:
b) Store the ID in some other encoding (thinking of HEX as B64 also contains /)
c) Any other good suggestions?
Regards,
Johannes