Conversation
...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 FSharp.AWS.DynamoDB/src/FSharp.AWS.DynamoDB/Expression/UpdateExpr.fs Lines 218 to 221 in b817b6d 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:
and I'm not sure how to tackle that error. |
An
ADDin an update expression lets you increment a number attribute which doesn't exist yet, treating it as zero. Trying to useSETto increment a non-existent attribute will throw:The current update operations allow
ADDing to a set attribute only (let ADD (path : Set<'T>) (values : seq<'T>)), this PR proposes adding support toADDto 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 supportADDing numbers without introducing those. Perhaps:TODO
module UpdateOperatorstype UpdateOperatorswith static operators soADDcan be overloaded with the various number types, andmodule UpdateOperatorswhich exposes the the current functions so it's not a breaking changeUpdateExprRecord