-
Notifications
You must be signed in to change notification settings - Fork 820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dictionary inconsistencies between store and patch for enum keys #18131
Comments
We will take a look. Meanwhile as a workaround you could write your own JsonConverter for that type that contains dictionary. |
I also noticed that the enums are not unique even after reduce. Edit: This index groups the results by day and spits out all the values. public class FooIndex : AbstractIndexCreationTask<Foo, FooIndex.Result>
{
public FooIndex()
{
Map = foos =>
from f in foos
from day in f.Days
select new Result
{
Day = day.Key,
Values = new[] { day.Value},
};
Reduce = results =>
from result in results
group result by new { result.Day } into g
select new Result
{
Day = g.Key.Day,
Values = g.SelectMany(x => x.Values).ToArray()
};
}
public class Result
{
public DayOfWeek Day { get; set; }
public string[] Values { get; set; }
}
} |
For reference, the issue is different: #18439 |
I just noticed that the value of public class DictionaryEnumKeysTests : RavenTestDriver
{
[Fact]
public void DictionaryEnumKeys()
{
using var store = GetDocumentStore();
using (var session = store.OpenSession())
{
var foo = new FooDictionaryEnum
{
Days = new() { { DayOfWeek.Monday, "monday-store" } },
};
session.Store(foo);
session.SaveChanges();
session.Advanced.Patch<FooDictionaryEnum, string>(foo.Id.ToString(), f => f.Days[DayOfWeek.Monday], "monday-patched");
session.SaveChanges();
}
OpenBrowser(store.Urls.First());
WaitForUserToContinueTheTest(store);
}
public class FooDictionaryEnum
{
public string Id { get; set; }
public Dictionary<DayOfWeek, string> Days { get; set; }
}
} |
SaveEnumsAsIntegers
Edit
Store always uses string keys and patch always uses integer keys no matter if
SaveEnumsAsIntegers
is specified or not.Store does not store enums as integers for dictionary keys when
SaveEnumsAsIntegers
is specified.However, Patch seems to use integrers for dictionary keys which results in inconsistent data.
Test case
Results
The text was updated successfully, but these errors were encountered: