Open NickDarvey opened 2 years ago
Specifically, I'm guessing we don't want various ADD_* functions, so I'm thinking of how we could support ADDing numbers without introducing those. Perhaps: Change module UpdateOperators to be a type UpdateOperators with static operators so ADD can be overloaded with the various number types
...which might look something like this...
/// Table Update operation placeholder type
type UpdateOp =
/// Combines two update operations into one
static member (&&&) (left : UpdateOp, right : UpdateOp) : UpdateOp =
invalidOp "Update combiner reserved for quoted update expressions."
static member ADD (path : Set<'T>, values : seq<'T>) : UpdateOp =
invalidOp "ADD operation reserved for quoted update expressions."
static member ADD (path : int64, value : int64) : UpdateOp =
invalidOp "ADD operation reserved for quoted update expressions."
/// Update expression special operators
[<AutoOpen>]
module UpdateOperators =
/// Assigns a record attribute path to given value
let SET (path : 'T) (value : 'T) : UpdateOp =
invalidOp "SET operation reserved for quoted update expressions."
/// Removes a record attribute path from entry
let REMOVE (path : 'T) : UpdateOp =
invalidOp "REMOVE operation reserved for quoted update expressions."
/// Adds given set of values to set attribute path
let inline ADD (path : Set<'T>) (values : seq<'T>) : UpdateOp =
UpdateOp.ADD (path, values)
/// Deletes given set of values to set attribute path
let DELETE (path : Set<'T>) (values : seq<'T>) : UpdateOp =
invalidOp "DELETE operation reserved for quoted update expressions."
However, I'm not sure where to go after updating this block
to
| SpecificCall2 <@ UpdateOp.ADD @> (None, _, _, [AttributeGet attr; value]) ->
// ~~~~~~~~~~~~~
let op = getOperand attr.Pickler value
attrs.Add attr
updateOps.Add (Add (attr.Id, op))
because I run in to:
A member or object constructor 'ADD' taking 1 arguments is not accessible from this code location. All accessible versions of method 'ADD' take 2 arguments.F# Compiler503
and I'm not sure how to tackle that error.
An
ADD
in an update expression lets you increment a number attribute which doesn't exist yet, treating it as zero. Trying to useSET
to increment a non-existent attribute will throw:The current update operations allow
ADD
ing to a set attribute only (let ADD (path : Set<'T>) (values : seq<'T>)
), this PR proposes adding support toADD
to a number attribute.It's in draft right now because I'm looking for guidance on how you want this contribution to be implemented, should you want this contribution. The current changes shown in this PR are just the
silliestsimplest thing to verify the tests would pass.Specifically, I'm guessing we don't want various
ADD_*
functions, so I'm thinking of how we could supportADD
ing numbers without introducing those. Perhaps:TODO
module UpdateOperators
type UpdateOperators
with static operators soADD
can be overloaded with the various number types, andmodule UpdateOperators
which exposes the the current functions so it's not a breaking changeUpdateExprRecord