Skip to content

Commit

Permalink
Merge pull request #214 from mfenniak/named_value_collection
Browse files Browse the repository at this point in the history
Support "Named Value Dictionaries" and dictionary related operations
  • Loading branch information
mfenniak committed Apr 18, 2015
2 parents d6f7c86 + f347aab commit 3dfde47
Show file tree
Hide file tree
Showing 19 changed files with 1,264 additions and 12 deletions.
9 changes: 9 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

### Features

* Add support for free-form objects or fields in the form of ```Dictionary<string, object>```, or ```Dictionary<string, TValue>``` without the use of rethinkdb-net-newtonsoft, and including a bunch of dictionary-specific functionality. [PR #214](https://github.com/mfenniak/rethinkdb-net/pull/214)

* ContainsValue method can be used in expressions, particularly filtering and map expression. eg. ```table.Filter(o => o.Properties.Contains("key"))```
* Keys and Values properties can be used to retrieve the keys and values of a dictionary as an array.
* Dictionary accessor can be used to access a key value, eg. ```table.Filter(o => o.Properties["key"] > 5)```
* New extension method ```SetValue``` on Dictionary can be used to add and update a value to a dictionary during an Update query, eg. ```table.Update(o => new User() { Properties = o.Properties.SetValue("new_key", "new_value") })``` will add or set the field "new_value" on the object "Properties".
* New extension method ```Without``` on Dictionary can be used to exclude a field from a table query.
* New automatic logic to determine the most appropriate native type to create when reading a ```Dictionary<string, object>``` from the server.

* Supports RethinkDB's regular expression matching of strings, eg. ```table.Filter(o => o.Email != null && o.Email.Match(".*@(.*)") != null)```. [Issue #107](https://github.com/mfenniak/rethinkdb-net/issues/107) & [PR #208](https://github.com/mfenniak/rethinkdb-net/pull/208)

* Expressions can now reference member variables of server-side calculated data, eg. ```table.Filter(o => o.Email.Match(".*@(.*)").Groups[0].MatchedString == "google.com")``` would filter for all records with an e-mail address that has a domain of "google.com". [PR #209](https://github.com/mfenniak/rethinkdb-net/pull/209)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using NUnit.Framework;
using System;
using FluentAssertions;
using Newtonsoft.Json.Linq;
using NUnit.Framework;
using RethinkDb.Newtonsoft.Configuration;
using RethinkDb.Test.Integration;

Expand Down Expand Up @@ -101,4 +104,29 @@ static NRealtimePushTests()
ConnectionFactory = ConfigurationAssembler.CreateConnectionFactory("testCluster");
}
}

[TestFixture]
public class NNamedValueDictionaryTests : NamedValueDictionaryTests
{
static NNamedValueDictionaryTests()
{
ConnectionFactory = ConfigurationAssembler.CreateConnectionFactory("testCluster");
}

protected override void MultipleItemSetterVerifyDictionary(TestObjectWithDictionary gil)
{
// FIXME: varies from the base class by:
// - skill level being a double type, rather than an int
// - updated at being a JObject, rather than a DateTimeOffset
// These are not the types I'd expect for these values, but, the RethinkDB datum converters are only plugged into the
// top level of the object with the newtonsoft converter, not the values inside a dictionary. This is debatably wrong,
// but, I'm not fixing it right now... the best solution might be to incorporate any technical requirements of the
// newtonsoft extension library into the core, and drop this extension library...
gil.FreeformProperties.Should().Contain("best known for", "being awesome");
gil.FreeformProperties.Should().Contain("skill level", 1000.0);
gil.FreeformProperties.Should().ContainKey("updated at");
gil.FreeformProperties ["updated at"].Should().BeOfType<JObject>();
gil.FreeformProperties.Should().HaveCount(5);
}
}
}
1 change: 1 addition & 0 deletions rethinkdb-net-newtonsoft/Configuration/NewtonSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public NewtonSerializer() : base(
AnonymousTypeDatumConverterFactory.Instance,
BoundEnumDatumConverterFactory.Instance,
NullableDatumConverterFactory.Instance,
NamedValueDictionaryDatumConverterFactory.Instance,
NewtonsoftDatumConverterFactory.Instance
)
{
Expand Down
Loading

0 comments on commit 3dfde47

Please sign in to comment.