Skip to content

Support merging for partial record properties #16

@eiriktsarpalis

Description

@eiriktsarpalis

I have identified a slight shortcoming in the way that the merge operation is exposed in the library. The problem is that you are always forced to update each and every property of the record representation, which can be problematic in certain applications. For example, consider the record:

type Record = { [<PartitionKey>] : string; [<RowKey>] : string ; Value1 : int; Value2 : int }

Supposing I only wanted to merge with respect to the second value, I would be have to be forced to fetch the original record, update the value in question, and then perform a full merge on the record properties.

As it is, the only way to overcome the problem is to create a second RecordPartial type that only contains the updated value in question, but I find this approach to be a bit problematic.

I've come up with the following idea. We could append the operation:

type Operation<'T> =
   ...
   | MergePartial of Expr<'T -> 'T> * etag:string
   ...

which could be used as follows:

    MergePartial <@ fun record -> { record with Value2 = 42 } @>

This would allow the library to build partial entities for merging in the expected way. Obviously it requires a bit of quotation manipulation to achieve this but in my experiments I've become convinced it is perfectly doable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions