Skip to content

Set an array as a new record #31

Description

@grendo

Hi,
looks like you can not set an array as a record. The DeepStreamRecordBase must be a JContainer. Should it be a JToken so it can support arrays ? Alternatively throw an exception if you try and set an array.

When you try and set an array this line does not merge anything
Data.Merge(item, jsonMergeSettings);

Here is a test

        [Test]
        public async Task TestSetArray()
        {
            var name = Guid.NewGuid().ToString();
            var key = @"my/testrecord/" + name;
            var obj = new JArray();
            obj.Add("hello");
            using (var client1 = await GetConnection("chris", "test"))
            {
                var record1 = await client1.Records.GetRecordAsync(key);
                var res = await client1.Records.SetWithAckAsync(record1, obj);
                Assert.IsTrue(res);
                var json = JsonConvert.SerializeObject(record1);
                Assert.IsTrue(json.StartsWith("["), "SHould be an array");
            }
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions