From b80d8a97759e554d7023987006ae81b5d2d608bb Mon Sep 17 00:00:00 2001 From: Sam Ritchie Date: Fri, 2 Feb 2024 20:02:55 +0800 Subject: [PATCH] Tweak max widths for gooder code --- .editorconfig | 4 +- build.fsx | 45 ++-- .../Expression/ConditionalExpr.fs | 27 +-- .../Expression/ExprCommon.fs | 14 +- .../Expression/ExpressionContainers.fs | 6 +- .../Expression/ProjectionExpr.fs | 27 +-- .../Expression/UpdateExpr.fs | 34 +-- src/FSharp.AWS.DynamoDB/Extensions.fs | 19 +- .../Picklers/CollectionPicklers.fs | 7 +- .../Picklers/PrimitivePicklers.fs | 10 +- .../Picklers/PropertyMetadata.fs | 6 +- .../Picklers/RecordPickler.fs | 12 +- .../Picklers/UnionPickler.fs | 12 +- src/FSharp.AWS.DynamoDB/RecordKeySchema.fs | 109 +++------ src/FSharp.AWS.DynamoDB/Script.fsx | 11 +- src/FSharp.AWS.DynamoDB/TableContext.fs | 207 +++++------------- src/FSharp.AWS.DynamoDB/Types.fs | 5 +- src/FSharp.AWS.DynamoDB/Utils/DynamoUtils.fs | 26 +-- src/FSharp.AWS.DynamoDB/Utils/Utils.fs | 17 +- .../ConditionalExpressionTests.fs | 117 +++------- .../MetricsCollectorTests.fs | 6 +- .../MultipleKeyAttributeTests.fs | 32 +-- .../PaginationTests.fs | 73 ++---- .../ProjectionExpressionTests.fs | 4 +- .../RecordGenerationTests.fs | 14 +- .../SimpleTableOperationTests.fs | 39 +--- .../SparseGSITests.fs | 3 +- .../UpdateExpressionTests.fs | 10 +- 28 files changed, 221 insertions(+), 675 deletions(-) diff --git a/.editorconfig b/.editorconfig index 3398f13..1fe1dbf 100644 --- a/.editorconfig +++ b/.editorconfig @@ -91,7 +91,7 @@ fsharp_max_if_then_else_short_width=60 # breaks an infix operator expression if it is on one line # infix: a + b + c # default 50 -fsharp_max_infix_operator_expression=60 +fsharp_max_infix_operator_expression=100 # breaks a single-line record declaration # i.e. if this gets too wide: { X = 10; Y = 12 } @@ -134,7 +134,7 @@ fsharp_max_value_binding_width=140 # maximum width for function and member binding (rh-side) # default 40 -fsharp_max_function_binding_width=80 +fsharp_max_function_binding_width=100 # maximum width for expressions like X.DoY().GetZ(10).Help() # default 50 diff --git a/build.fsx b/build.fsx index 3cf6220..0e9271f 100755 --- a/build.fsx +++ b/build.fsx @@ -2,7 +2,7 @@ #r "nuget: Fake.Core.Target" // Boilerplate -System.Environment.GetCommandLineArgs () +System.Environment.GetCommandLineArgs() |> Array.skip 2 // skip fsi.exe; build.fsx |> Array.toList |> Fake.Core.Context.FakeExecutionContext.Create false __SOURCE_FILE__ @@ -90,20 +90,20 @@ Target.create "AssemblyInfo" (fun _ -> AssemblyInfo.Description summary AssemblyInfo.Version release.AssemblyVersion AssemblyInfo.FileVersion release.AssemblyVersion - AssemblyInfo.InternalsVisibleTo (projectName + ".Tests") ] + AssemblyInfo.InternalsVisibleTo(projectName + ".Tests") ] let getProjectDetails (projectPath: string) = - let projectName = System.IO.Path.GetFileNameWithoutExtension (projectPath) - (projectPath, projectName, System.IO.Path.GetDirectoryName (projectPath), (getAssemblyInfoAttributes projectName)) + let projectName = System.IO.Path.GetFileNameWithoutExtension(projectPath) + (projectPath, projectName, System.IO.Path.GetDirectoryName(projectPath), (getAssemblyInfoAttributes projectName)) !! "src/**/*.??proj" |> Seq.map getProjectDetails |> Seq.iter (fun (projFileName, _, folderName, attributes) -> match projFileName with - | proj when proj.EndsWith ("fsproj") -> AssemblyInfoFile.createFSharp (folderName "AssemblyInfo.fs") attributes - | proj when proj.EndsWith ("csproj") -> + | proj when proj.EndsWith("fsproj") -> AssemblyInfoFile.createFSharp (folderName "AssemblyInfo.fs") attributes + | proj when proj.EndsWith("csproj") -> AssemblyInfoFile.createCSharp ((folderName "Properties") "AssemblyInfo.cs") attributes - | proj when proj.EndsWith ("vbproj") -> + | proj when proj.EndsWith("vbproj") -> AssemblyInfoFile.createVisualBasic ((folderName "My Project") "AssemblyInfo.vb") attributes | _ -> ())) @@ -155,11 +155,11 @@ Target.create "Pack" (fun _ -> Target.create "ReleaseGitHub" (fun _ -> let remote = Git.CommandHelper.getGitResult "" "remote -v" - |> Seq.filter (fun (s: string) -> s.EndsWith ("(push)")) - |> Seq.tryFind (fun (s: string) -> s.Contains (gitOwner + "/" + gitName)) + |> Seq.filter (fun (s: string) -> s.EndsWith("(push)")) + |> Seq.tryFind (fun (s: string) -> s.Contains(gitOwner + "/" + gitName)) |> function | None -> gitHome + "/" + gitName - | Some (s: string) -> s.Split().[0] + | Some(s: string) -> s.Split().[0] Git.Staging.stageAll "" Git.Commit.exec "" (sprintf "Bump version to %s" release.NugetVersion) @@ -196,7 +196,7 @@ Target.create "Push" (fun _ -> | _ -> UserInput.getUserPassword "NuGet Key: " let pushParams = - { NuGet.NuGet.NuGetPushParams.Create () with + { NuGet.NuGet.NuGetPushParams.Create() with ApiKey = Some key Source = Some "https://api.nuget.org/v3/index.json" } @@ -208,23 +208,10 @@ Target.create "Push" (fun _ -> Target.create "Default" DoNothing Target.create "Release" DoNothing -"Clean" -==> "AssemblyInfo" -==> "Restore" -==> "Build" -==> "Test" -==> "Default" - -"Clean" -==> "AssemblyInfo" -==> "Restore" -==> "BuildRelease" -==> "Docs" - -"Default" -==> "Pack" -==> "ReleaseGitHub" -==> "Push" -==> "Release" +"Clean" ==> "AssemblyInfo" ==> "Restore" ==> "Build" ==> "Test" ==> "Default" + +"Clean" ==> "AssemblyInfo" ==> "Restore" ==> "BuildRelease" ==> "Docs" + +"Default" ==> "Pack" ==> "ReleaseGitHub" ==> "Push" ==> "Release" Target.runOrDefaultWithArguments "Default" diff --git a/src/FSharp.AWS.DynamoDB/Expression/ConditionalExpr.fs b/src/FSharp.AWS.DynamoDB/Expression/ConditionalExpr.fs index 2deb8bf..64c775f 100644 --- a/src/FSharp.AWS.DynamoDB/Expression/ConditionalExpr.fs +++ b/src/FSharp.AWS.DynamoDB/Expression/ConditionalExpr.fs @@ -164,9 +164,7 @@ let extractQueryExpr (recordInfo: RecordTableInfo) (expr: Expr) : ConditionalExp if not expr.IsClosed then invalidArg "expr" "supplied query is not a closed expression." - let invalidQuery () = - invalidArg "expr" - <| sprintf "Supplied expression is not a valid conditional." + let invalidQuery () = invalidArg "expr" <| sprintf "Supplied expression is not a valid conditional." let nParams, (|PVar|_|), expr' = extractExprParams recordInfo expr @@ -223,10 +221,7 @@ let extractQueryExpr (recordInfo: RecordTableInfo) (expr: Expr) : ConditionalExp let op = extractOperand None expr match op with - | Value va -> - va.AttributeValue.L - |> ResizeArray.mapToArray (fun x -> x |> wrap |> Value) - |> Some + | Value va -> va.AttributeValue.L |> ResizeArray.mapToArray (fun x -> x |> wrap |> Value) |> Some | _ -> None let extractNestedField (expr: Expr) = @@ -241,10 +236,7 @@ let extractQueryExpr (recordInfo: RecordTableInfo) (expr: Expr) : ConditionalExp let (|Comparison|_|) (pat: Expr) (expr: Expr) = match expr with | SpecificCall pat (None, _, args) -> - let pickler = - args - |> List.tryPick (|AttributeGet|_|) - |> Option.map (fun attr -> attr.Pickler) + let pickler = args |> List.tryPick (|AttributeGet|_|) |> Option.map (fun attr -> attr.Pickler) let operands = args |> List.map (extractOperand pickler) @@ -259,8 +251,7 @@ let extractQueryExpr (recordInfo: RecordTableInfo) (expr: Expr) : ConditionalExp let extractComparison (p: Pickler) (cmp: Comparator) (left: Operand) (right: Operand) = if cmp.IsComparison && not p.IsComparable then - sprintf "Representation of type '%O' does not support comparisons." p.Type - |> invalidArg "expr" + sprintf "Representation of type '%O' does not support comparisons." p.Type |> invalidArg "expr" elif left = right then match cmp with @@ -536,15 +527,9 @@ type ConditionalExpression with let aw = new AttributeWriter() let expr = writeConditionExpression aw cond - let names = - aw.Names - |> Seq.map (fun kv -> kv.Key, kv.Value) - |> Seq.toList + let names = aw.Names |> Seq.map (fun kv -> kv.Key, kv.Value) |> Seq.toList - let values = - aw.Values - |> Seq.map (fun kv -> kv.Key, kv.Value.Print()) - |> Seq.toList + let values = aw.Values |> Seq.map (fun kv -> kv.Key, kv.Value.Print()) |> Seq.toList expr, names, values diff --git a/src/FSharp.AWS.DynamoDB/Expression/ExprCommon.fs b/src/FSharp.AWS.DynamoDB/Expression/ExprCommon.fs index 3692d6e..f5241f4 100644 --- a/src/FSharp.AWS.DynamoDB/Expression/ExprCommon.fs +++ b/src/FSharp.AWS.DynamoDB/Expression/ExprCommon.fs @@ -25,9 +25,7 @@ type NestedAttribute = member nf.Print() = match nf with | FParam i -> sprintf "<$param%d>" i - | FField f when not <| isValidFieldName f -> - sprintf "map keys must be 1 to 64k long (as utf8)." - |> invalidArg f + | FField f when not <| isValidFieldName f -> sprintf "map keys must be 1 to 64k long (as utf8)." |> invalidArg f | FField f -> "." + f | FIndex i -> sprintf "[%d]" i @@ -182,15 +180,9 @@ type QuotedAttribute = let tryGetPropInfo (properties: PropertyMetadata[]) isFinalProp (p: PropertyInfo) = match properties |> Array.tryFind (fun rp -> rp.PropertyInfo = p) with | None -> None - | Some rp when - rp.Pickler.PicklerType = PicklerType.Serialized - && not isFinalProp - -> + | Some rp when rp.Pickler.PicklerType = PicklerType.Serialized && not isFinalProp -> invalidArg "expr" "cannot access nested properties of serialized fields." - | Some rp when - rp.Pickler.PicklerType = PicklerType.Union - && not isFinalProp - -> + | Some rp when rp.Pickler.PicklerType = PicklerType.Union && not isFinalProp -> invalidArg "expr" "cannot access nested properties of union fields." | Some _ as r -> r diff --git a/src/FSharp.AWS.DynamoDB/Expression/ExpressionContainers.fs b/src/FSharp.AWS.DynamoDB/Expression/ExpressionContainers.fs index 2b33281..3161b2a 100644 --- a/src/FSharp.AWS.DynamoDB/Expression/ExpressionContainers.fs +++ b/src/FSharp.AWS.DynamoDB/Expression/ExpressionContainers.fs @@ -96,11 +96,7 @@ and UpdateExpression = let uops = exprs |> Array.collect (fun e -> e.UpdateOps.UpdateOps) - match - uops - |> Seq.map (fun o -> o.Attribute) - |> tryFindConflictingPaths - with + match uops |> Seq.map (fun o -> o.Attribute) |> tryFindConflictingPaths with | None -> () | Some(p1, p2) -> let msg = sprintf "found conflicting paths '%s' and '%s' being accessed in update expression." p1 p2 diff --git a/src/FSharp.AWS.DynamoDB/Expression/ProjectionExpr.fs b/src/FSharp.AWS.DynamoDB/Expression/ProjectionExpr.fs index 700095d..f2281b9 100644 --- a/src/FSharp.AWS.DynamoDB/Expression/ProjectionExpr.fs +++ b/src/FSharp.AWS.DynamoDB/Expression/ProjectionExpr.fs @@ -28,9 +28,7 @@ type AttributeId with if List.isEmpty rest then false else - sprintf "Document path '%s' not found." id.Name - |> KeyNotFoundException - |> raise + sprintf "Document path '%s' not found." id.Name |> KeyNotFoundException |> raise let rec aux result rest (av: AttributeValue) = match rest with @@ -42,28 +40,18 @@ type AttributeId with let ok, nested = av.M.TryGetValue f if not ok then notFound tl else aux result tl nested else - av.Print() - |> sprintf "Expected map, but was '%s'." - |> InvalidCastException - |> raise + av.Print() |> sprintf "Expected map, but was '%s'." |> InvalidCastException |> raise | FIndex i :: tl -> if av.IsLSet then if i < 0 || i >= av.L.Count then - sprintf "Indexed path '%s' out of range." id.Name - |> ArgumentOutOfRangeException - |> raise + sprintf "Indexed path '%s' out of range." id.Name |> ArgumentOutOfRangeException |> raise else aux result tl av.L.[i] else - av.Print() - |> sprintf "Expected list, but was '%s'." - |> InvalidCastException - |> raise + av.Print() |> sprintf "Expected list, but was '%s'." |> InvalidCastException |> raise - | FParam _ :: _ -> - sprintf "internal error; unexpected attribute path '%s'." id.Name - |> invalidOp + | FParam _ :: _ -> sprintf "internal error; unexpected attribute path '%s'." id.Name |> invalidOp let ok, prop = ro.TryGetValue id.RootName @@ -171,9 +159,6 @@ type ProjectionExpr = let aw = new AttributeWriter() let expr = __.Write(aw) - let names = - aw.Names - |> Seq.map (fun kv -> kv.Key, kv.Value) - |> Seq.toList + let names = aw.Names |> Seq.map (fun kv -> kv.Key, kv.Value) |> Seq.toList expr, names diff --git a/src/FSharp.AWS.DynamoDB/Expression/UpdateExpr.fs b/src/FSharp.AWS.DynamoDB/Expression/UpdateExpr.fs index 2cc6308..ec0f2bc 100644 --- a/src/FSharp.AWS.DynamoDB/Expression/UpdateExpr.fs +++ b/src/FSharp.AWS.DynamoDB/Expression/UpdateExpr.fs @@ -142,9 +142,7 @@ let extractRecordExprUpdaters (recordInfo: RecordTableInfo) (expr: Expr) : Inter if not expr.IsClosed then invalidArg "expr" "supplied update expression contains free variables." - let invalidExpr () = - invalidArg "expr" - <| sprintf "Supplied expression is not a valid update expression." + let invalidExpr () = invalidArg "expr" <| sprintf "Supplied expression is not a valid update expression." let nParams, pRecognizer, expr' = extractExprParams recordInfo expr @@ -166,11 +164,7 @@ let extractRecordExprUpdaters (recordInfo: RecordTableInfo) (expr: Expr) : Inter | Var v when bindings.ContainsKey v -> Some(Root(rp, recordInfo.GetPropertySchemata rp.Name), bindings.[v]) | e -> Some(Root(rp, recordInfo.GetPropertySchemata rp.Name), e) - let assignmentExprs = - assignments - |> Seq.mapi tryExtractValueExpr - |> Seq.choose id - |> Seq.toArray + let assignmentExprs = assignments |> Seq.mapi tryExtractValueExpr |> Seq.choose id |> Seq.toArray { RVar = r NParams = nParams @@ -187,9 +181,7 @@ let extractOpExprUpdaters (recordInfo: RecordTableInfo) (expr: Expr) : Intermedi if not expr.IsClosed then invalidArg "expr" "supplied update expression contains free variables." - let invalidExpr () = - invalidArg "expr" - <| sprintf "Supplied expression is not a valid update expression." + let invalidExpr () = invalidArg "expr" <| sprintf "Supplied expression is not a valid update expression." let nParams, (|PVar|_|), expr' = extractExprParams recordInfo expr @@ -239,11 +231,7 @@ let extractOpExprUpdaters (recordInfo: RecordTableInfo) (expr: Expr) : Intermedi do extract body - match - attrs - |> Seq.map (fun attr -> attr.Id) - |> tryFindConflictingPaths - with + match attrs |> Seq.map (fun attr -> attr.Id) |> tryFindConflictingPaths with | Some(p1, p2) -> let msg = sprintf "found conflicting paths '%s' and '%s' being accessed in update expression." p1 p2 invalidArg "expr" msg @@ -264,9 +252,7 @@ let extractOpExprUpdaters (recordInfo: RecordTableInfo) (expr: Expr) : Intermedi /// Completes conversion from intermediate update expression to final update operations let extractUpdateOps (exprs: IntermediateUpdateExprs) = - let invalidExpr () = - invalidArg "expr" - <| sprintf "Supplied expression is not a valid update expression." + let invalidExpr () = invalidArg "expr" <| sprintf "Supplied expression is not a valid update expression." let (|PVar|_|) = exprs.ParamRecognizer let (|AttributeGet|_|) (e: Expr) = QuotedAttribute.TryExtract (|PVar|_|) exprs.RVar exprs.RecordInfo e @@ -520,15 +506,9 @@ type UpdateOperations with let aw = new AttributeWriter() let expr = writeUpdateExpression aw uops - let names = - aw.Names - |> Seq.map (fun kv -> kv.Key, kv.Value) - |> Seq.toList + let names = aw.Names |> Seq.map (fun kv -> kv.Key, kv.Value) |> Seq.toList - let values = - aw.Values - |> Seq.map (fun kv -> kv.Key, kv.Value.Print()) - |> Seq.toList + let values = aw.Values |> Seq.map (fun kv -> kv.Key, kv.Value.Print()) |> Seq.toList expr, names, values diff --git a/src/FSharp.AWS.DynamoDB/Extensions.fs b/src/FSharp.AWS.DynamoDB/Extensions.fs index 9316627..4acfc70 100644 --- a/src/FSharp.AWS.DynamoDB/Extensions.fs +++ b/src/FSharp.AWS.DynamoDB/Extensions.fs @@ -51,15 +51,9 @@ module Extensions = let getEnv x = Environment.ResolveEnvironmentVariable x match getEnv accessKeyName, getEnv secretKeyName with - | null, null -> - sprintf "Undefined environment variables '%s' and '%s'" accessKeyName secretKeyName - |> invalidOp - | null, _ -> - sprintf "Undefined environment variable '%s'" accessKeyName - |> invalidOp - | _, null -> - sprintf "Undefined environment variable '%s'" secretKeyName - |> invalidOp + | null, null -> sprintf "Undefined environment variables '%s' and '%s'" accessKeyName secretKeyName |> invalidOp + | null, _ -> sprintf "Undefined environment variable '%s'" accessKeyName |> invalidOp + | _, null -> sprintf "Undefined environment variable '%s'" secretKeyName |> invalidOp | aK, sK -> new BasicAWSCredentials(aK, sK) :> _ /// @@ -77,8 +71,7 @@ module Extensions = let credsFile = Path.Combine(getHomePath (), ".aws", "credentials") if not <| File.Exists credsFile then - sprintf "Could not locate stored credentials profile '%s'." profileName - |> invalidOp + sprintf "Could not locate stored credentials profile '%s'." profileName |> invalidOp let text = File.ReadAllText credsFile @@ -89,7 +82,5 @@ module Extensions = |> Seq.tryFind (fun (pf, _, _) -> pf = profileName) match matchingProfile with - | None -> - sprintf "Could not locate stored credentials profile '%s'." profileName - |> invalidOp + | None -> sprintf "Could not locate stored credentials profile '%s'." profileName |> invalidOp | Some(_, aK, sK) -> new BasicAWSCredentials(aK, sK) :> _ diff --git a/src/FSharp.AWS.DynamoDB/Picklers/CollectionPicklers.fs b/src/FSharp.AWS.DynamoDB/Picklers/CollectionPicklers.fs index efb6629..c2b7284 100644 --- a/src/FSharp.AWS.DynamoDB/Picklers/CollectionPicklers.fs +++ b/src/FSharp.AWS.DynamoDB/Picklers/CollectionPicklers.fs @@ -57,8 +57,7 @@ type BytesSetPickler() = if bs.Length = 0 then None else - Some - <| AttributeValue(BS = rlist [| new MemoryStream(bs) |]) + Some <| AttributeValue(BS = rlist [| new MemoryStream(bs) |]) | _ -> let rl = @@ -190,9 +189,7 @@ type MapPickler<'Value>(vp: Pickler<'Value>) = if a.NULL then Map.empty elif a.IsMSet then - a.M - |> Seq.map (fun kv -> kv.Key, vp.UnPickle kv.Value) - |> Map.ofSeq + a.M |> Seq.map (fun kv -> kv.Key, vp.UnPickle kv.Value) |> Map.ofSeq else invalidCast a diff --git a/src/FSharp.AWS.DynamoDB/Picklers/PrimitivePicklers.fs b/src/FSharp.AWS.DynamoDB/Picklers/PrimitivePicklers.fs index 3bc2190..773766f 100644 --- a/src/FSharp.AWS.DynamoDB/Picklers/PrimitivePicklers.fs +++ b/src/FSharp.AWS.DynamoDB/Picklers/PrimitivePicklers.fs @@ -69,11 +69,9 @@ let inline mkNumericalPickler< ^N when ^N: (static member Parse: string * IFormatProvider -> ^N) and ^N: (member ToString: IFormatProvider -> string)> () = - let inline parseNum s = - (^N: (static member Parse: string * IFormatProvider -> ^N) (s, CultureInfo.InvariantCulture)) + let inline parseNum s = (^N: (static member Parse: string * IFormatProvider -> ^N) (s, CultureInfo.InvariantCulture)) - let inline toString n = - (^N: (member ToString: IFormatProvider -> string) (n, CultureInfo.InvariantCulture)) + let inline toString n = (^N: (member ToString: IFormatProvider -> string) (n, CultureInfo.InvariantCulture)) { new NumRepresentablePickler< ^N >() with member _.PickleType = PickleType.Number @@ -291,9 +289,7 @@ type SerializerAttributePickler<'T>(serializer: IPropertySerializer, resolver: I override _.PickleType = picklePickler.PickleType override _.PicklerType = PicklerType.Serialized - override _.DefaultValue = - raise - <| NotSupportedException("Default values not supported in serialized types.") + override _.DefaultValue = raise <| NotSupportedException("Default values not supported in serialized types.") override _.Pickle value = let pickle = serializer.Serialize value diff --git a/src/FSharp.AWS.DynamoDB/Picklers/PropertyMetadata.fs b/src/FSharp.AWS.DynamoDB/Picklers/PropertyMetadata.fs index 4e3680d..1f6f762 100644 --- a/src/FSharp.AWS.DynamoDB/Picklers/PropertyMetadata.fs +++ b/src/FSharp.AWS.DynamoDB/Picklers/PropertyMetadata.fs @@ -40,11 +40,7 @@ type PropertyMetadata = | _ -> None) with | Some serializer -> mkSerializerAttributePickler resolver serializer prop.PropertyType - | None when - attributes - |> containsAttribute - -> - mkStringRepresentationPickler resolver prop + | None when attributes |> containsAttribute -> mkStringRepresentationPickler resolver prop | None -> resolver.Resolve prop.PropertyType let name = diff --git a/src/FSharp.AWS.DynamoDB/Picklers/RecordPickler.fs b/src/FSharp.AWS.DynamoDB/Picklers/RecordPickler.fs index 82cc009..81328f2 100644 --- a/src/FSharp.AWS.DynamoDB/Picklers/RecordPickler.fs +++ b/src/FSharp.AWS.DynamoDB/Picklers/RecordPickler.fs @@ -39,9 +39,7 @@ type RecordPickler<'T>(ctor: obj[] -> obj, properties: PropertyMetadata[]) = for i = 0 to properties.Length - 1 do let prop = properties.[i] - let notFound () = - raise - <| new KeyNotFoundException(sprintf "attribute %A not found." prop.Name) + let notFound () = raise <| new KeyNotFoundException(sprintf "attribute %A not found." prop.Name) let ok, av = ro.TryGetValue prop.Name @@ -58,9 +56,7 @@ type RecordPickler<'T>(ctor: obj[] -> obj, properties: PropertyMetadata[]) = override __.PickleType = PickleType.Map override __.DefaultValue = - let defaultFields = - properties - |> Array.map (fun p -> p.Pickler.DefaultValueUntyped) + let defaultFields = properties |> Array.map (fun p -> p.Pickler.DefaultValueUntyped) ctor defaultFields :?> 'T @@ -85,9 +81,7 @@ type PropertyMetadata with let mkTuplePickler<'T> (resolver: IPicklerResolver) = let ctor = FSharpValue.PreComputeTupleConstructor typeof<'T> - let properties = - typeof<'T>.GetProperties() - |> Array.mapi (PropertyMetadata.FromPropertyInfo resolver) + let properties = typeof<'T>.GetProperties() |> Array.mapi (PropertyMetadata.FromPropertyInfo resolver) new RecordPickler<'T>(ctor, properties) diff --git a/src/FSharp.AWS.DynamoDB/Picklers/UnionPickler.fs b/src/FSharp.AWS.DynamoDB/Picklers/UnionPickler.fs index 00e327a..99d9096 100644 --- a/src/FSharp.AWS.DynamoDB/Picklers/UnionPickler.fs +++ b/src/FSharp.AWS.DynamoDB/Picklers/UnionPickler.fs @@ -27,9 +27,7 @@ type UnionPickler<'U>(resolver: IPicklerResolver) = let mkUCD uci = let ctor = FSharpValue.PreComputeUnionConstructorInfo(uci, true) - let props = - uci.GetFields() - |> Array.mapi (PropertyMetadata.FromPropertyInfo resolver) + let props = uci.GetFields() |> Array.mapi (PropertyMetadata.FromPropertyInfo resolver) { UCI = uci; CaseCtor = ctor; Properties = props } @@ -51,9 +49,7 @@ type UnionPickler<'U>(resolver: IPicklerResolver) = values member __.ToUnion(ro: RestObject) : 'U = - let notFound name = - raise - <| new KeyNotFoundException(sprintf "attribute %A not found." name) + let notFound name = raise <| new KeyNotFoundException(sprintf "attribute %A not found." name) let tag = let ok, av = ro.TryGetValue caseAttr @@ -86,9 +82,7 @@ type UnionPickler<'U>(resolver: IPicklerResolver) = override __.PicklerType = PicklerType.Union override __.PickleType = PickleType.Map - override __.DefaultValue = - invalidOp - <| sprintf "default values not supported for unions." + override __.DefaultValue = invalidOp <| sprintf "default values not supported for unions." override __.Pickle(union: 'U) = let ro = __.OfUnion union diff --git a/src/FSharp.AWS.DynamoDB/RecordKeySchema.fs b/src/FSharp.AWS.DynamoDB/RecordKeySchema.fs index d0e7eb5..f11dd98 100644 --- a/src/FSharp.AWS.DynamoDB/RecordKeySchema.fs +++ b/src/FSharp.AWS.DynamoDB/RecordKeySchema.fs @@ -115,9 +115,7 @@ type PrimaryKeyStructure with /// Extracts key from attribute values static member ExtractKey(keyStructure: PrimaryKeyStructure, attributeValues: Dictionary) = let inline getValue (rp: PropertyMetadata) = - let notFound () = - raise - <| KeyNotFoundException(sprintf "attribute %A not found." rp.Name) + let notFound () = raise <| KeyNotFoundException(sprintf "attribute %A not found." rp.Name) let ok, av = attributeValues.TryGetValue rp.Name if ok then rp.Pickler.UnPickleUntyped av else notFound () @@ -138,25 +136,18 @@ type PrimaryKeyStructure with type KeyAttributeSchema with static member Create(name: string, pickler: Pickler, allowNull: bool) = - if - pickler.PicklerType <> PicklerType.Value - && pickler.PicklerType <> PicklerType.Wrapper - then - invalidArg name - <| sprintf "Unsupported type '%O' for DynamoDB Key attribute." pickler.Type + if pickler.PicklerType <> PicklerType.Value && pickler.PicklerType <> PicklerType.Wrapper then + invalidArg name <| sprintf "Unsupported type '%O' for DynamoDB Key attribute." pickler.Type if pickler.PicklerType = PicklerType.Wrapper && not allowNull then - invalidArg name - <| "DynamoDB Primary Key attributes can't be nullable or option" + invalidArg name <| "DynamoDB Primary Key attributes can't be nullable or option" let keyType = match pickler.PickleType with | PickleType.String -> ScalarAttributeType.S | PickleType.Number -> ScalarAttributeType.N | PickleType.Bytes -> ScalarAttributeType.B - | _ -> - invalidArg name - <| sprintf "Unsupported type '%O' for DynamoDB Key attribute." pickler.Type + | _ -> invalidArg name <| sprintf "Unsupported type '%O' for DynamoDB Key attribute." pickler.Type { AttributeName = name; KeyType = keyType } @@ -222,31 +213,23 @@ type RecordTableInfo with if not <| isValidKeyName hkca.Name then invalidArg hkca.Name "invalid HashKey name; must be 1 to 255 bytes long (as utf8)." - if - pickler.Properties - |> Array.exists (fun p -> p.Name = hkca.Name) - then + if pickler.Properties |> Array.exists (fun p -> p.Name = hkca.Name) then invalidArg (string typeof<'T>) "Default HashKey attribute contains conflicting name." let pickler = Pickler.resolveUntyped hkca.HashKeyType - DefaultHashKey(hkca.Name, hkca.HashKey, pickler, rk) - |> setResult + DefaultHashKey(hkca.Name, hkca.HashKey, pickler, rk) |> setResult | None, Some rkca, [| (KeyType.Hash, hk) |] -> if not <| isValidKeyName rkca.Name then invalidArg rkca.Name "invalid rangekey name; must be 1 to 255 bytes long (as utf8)." - if - pickler.Properties - |> Array.exists (fun p -> p.Name = rkca.Name) - then + if pickler.Properties |> Array.exists (fun p -> p.Name = rkca.Name) then invalidArg (string typeof<'T>) "Default RangeKey attribute contains conflicting name." let pickler = Pickler.resolveUntyped rkca.HashKeyType - DefaultRangeKey(rkca.Name, rkca.RangeKey, pickler, hk) - |> setResult + DefaultRangeKey(rkca.Name, rkca.RangeKey, pickler, hk) |> setResult | None, None, [| (KeyType.Hash, hk) |] -> HashKeyOnly(hk) |> setResult | None, None, [| (KeyType.Hash, hk); (KeyType.Range, rk) |] -> Combined(hk, rk) |> setResult @@ -254,12 +237,9 @@ type RecordTableInfo with | LocalSecondaryIndex _, [| (KeyType.Range, rk) |] -> match !primaryKey with - | None -> - "Does not specify a HashKey attribute." - |> invalidArg (string typeof<'T>) + | None -> "Does not specify a HashKey attribute." |> invalidArg (string typeof<'T>) | Some(_, ks) when Option.isNone ks.RangeKey -> - "LocalSecondaryIndex tables must specify a primary RangeKey" - |> invalidArg (string typeof<'T>) + "LocalSecondaryIndex tables must specify a primary RangeKey" |> invalidArg (string typeof<'T>) | Some(_, ks) -> { ks with RangeKey = Some(mkKAS rk); Type = kst } @@ -291,9 +271,7 @@ type RecordTableInfo with |> Seq.toArray match !primaryKey with - | None -> - "Does not specify a HashKey attribute." - |> invalidArg (string typeof<'T>) + | None -> "Does not specify a HashKey attribute." |> invalidArg (string typeof<'T>) | Some(pkStruct, pkSchema) -> let propSchema = @@ -308,10 +286,7 @@ type RecordTableInfo with }) |> Seq.groupBy (fun (a, _, _) -> a.AttributeName) |> Seq.map (fun (name, kss) -> - let schemata = - kss - |> Seq.map (fun (_, isHashKey, ks) -> ks, isHashKey) - |> Seq.toArray + let schemata = kss |> Seq.map (fun (_, isHashKey, ks) -> ks, isHashKey) |> Seq.toArray name, schemata) |> Map.ofSeq @@ -335,13 +310,9 @@ type RecordTableInfo with attributeValues: Dictionary ) = let inline getValue (ks: KeyAttributeSchema) = - let notFound () = - raise - <| KeyNotFoundException(sprintf "attribute %A not found." ks.AttributeName) + let notFound () = raise <| KeyNotFoundException(sprintf "attribute %A not found." ks.AttributeName) - let meta = - recordInfo.Properties - |> Array.find (fun p -> p.Name = ks.AttributeName) + let meta = recordInfo.Properties |> Array.find (fun p -> p.Name = ks.AttributeName) let ok, av = attributeValues.TryGetValue ks.AttributeName if ok then meta.Pickler.UnPickleUntyped av else notFound () @@ -372,9 +343,7 @@ type RecordTableInfo with if isNull value then invalidArg ks.AttributeName "Key value was not specified." - let meta = - recordInfo.Properties - |> Array.find (fun p -> p.Name = ks.AttributeName) + let meta = recordInfo.Properties |> Array.find (fun p -> p.Name = ks.AttributeName) let av = meta.Pickler.PickleUntyped value |> Option.get dict.[ks.AttributeName] <- av @@ -394,17 +363,12 @@ type TableKeySchemata with /// Extract key schema from DynamoDB table description object static member OfTableDescription(td: TableDescription) : TableKeySchemata = let mkKeySchema (kse: KeySchemaElement) = - let ad = - td.AttributeDefinitions - |> Seq.find (fun ad -> ad.AttributeName = kse.AttributeName) + let ad = td.AttributeDefinitions |> Seq.find (fun ad -> ad.AttributeName = kse.AttributeName) { AttributeName = kse.AttributeName; KeyType = ad.AttributeType } let primaryKey = - { HashKey = - td.KeySchema - |> Seq.find (fun ks -> ks.KeyType = KeyType.HASH) - |> mkKeySchema + { HashKey = td.KeySchema |> Seq.find (fun ks -> ks.KeyType = KeyType.HASH) |> mkKeySchema RangeKey = td.KeySchema |> Seq.tryPick (fun ks -> @@ -422,14 +386,8 @@ type TableKeySchemata with gsid.Projection.ProjectionType |> invalidOp - { HashKey = - gsid.KeySchema - |> Seq.find (fun ks -> ks.KeyType = KeyType.HASH) - |> mkKeySchema - RangeKey = - gsid.KeySchema - |> Seq.tryFind (fun ks -> ks.KeyType = KeyType.RANGE) - |> Option.map mkKeySchema + { HashKey = gsid.KeySchema |> Seq.find (fun ks -> ks.KeyType = KeyType.HASH) |> mkKeySchema + RangeKey = gsid.KeySchema |> Seq.tryFind (fun ks -> ks.KeyType = KeyType.RANGE) |> Option.map mkKeySchema Type = GlobalSecondaryIndex gsid.IndexName } let mkLocalSecondaryIndex (lsid: LocalSecondaryIndexDescription) : TableKeySchema = @@ -441,11 +399,7 @@ type TableKeySchemata with |> invalidOp { HashKey = primaryKey.HashKey - RangeKey = - lsid.KeySchema - |> Seq.find (fun ks -> ks.KeyType = KeyType.RANGE) - |> mkKeySchema - |> Some + RangeKey = lsid.KeySchema |> Seq.find (fun ks -> ks.KeyType = KeyType.RANGE) |> mkKeySchema |> Some Type = LocalSecondaryIndex lsid.IndexName } TableKeySchemata( @@ -463,26 +417,21 @@ type TableKeySchemata with for tks in schema.Schemata do keyAttrs.[tks.HashKey.AttributeName] <- tks.HashKey - tks.RangeKey - |> Option.iter (fun rk -> keyAttrs.[rk.AttributeName] <- rk) + tks.RangeKey |> Option.iter (fun rk -> keyAttrs.[rk.AttributeName] <- rk) match tks.Type with | PrimaryKey -> - ctr.KeySchema.Add - <| mkKSE tks.HashKey.AttributeName KeyType.HASH + ctr.KeySchema.Add <| mkKSE tks.HashKey.AttributeName KeyType.HASH - tks.RangeKey - |> Option.iter (fun rk -> ctr.KeySchema.Add <| mkKSE rk.AttributeName KeyType.RANGE) + tks.RangeKey |> Option.iter (fun rk -> ctr.KeySchema.Add <| mkKSE rk.AttributeName KeyType.RANGE) | GlobalSecondaryIndex name -> let gsi = new GlobalSecondaryIndex() gsi.IndexName <- name - gsi.KeySchema.Add - <| mkKSE tks.HashKey.AttributeName KeyType.HASH + gsi.KeySchema.Add <| mkKSE tks.HashKey.AttributeName KeyType.HASH - tks.RangeKey - |> Option.iter (fun rk -> gsi.KeySchema.Add <| mkKSE rk.AttributeName KeyType.RANGE) + tks.RangeKey |> Option.iter (fun rk -> gsi.KeySchema.Add <| mkKSE rk.AttributeName KeyType.RANGE) gsi.Projection <- Projection(ProjectionType = ProjectionType.ALL) ctr.GlobalSecondaryIndexes.Add gsi @@ -491,11 +440,9 @@ type TableKeySchemata with let lsi = new LocalSecondaryIndex() lsi.IndexName <- name - lsi.KeySchema.Add - <| mkKSE tks.HashKey.AttributeName KeyType.HASH + lsi.KeySchema.Add <| mkKSE tks.HashKey.AttributeName KeyType.HASH - tks.RangeKey - |> Option.iter (fun rk -> lsi.KeySchema.Add <| mkKSE rk.AttributeName KeyType.RANGE) + tks.RangeKey |> Option.iter (fun rk -> lsi.KeySchema.Add <| mkKSE rk.AttributeName KeyType.RANGE) lsi.Projection <- Projection(ProjectionType = ProjectionType.ALL) ctr.LocalSecondaryIndexes.Add lsi diff --git a/src/FSharp.AWS.DynamoDB/Script.fsx b/src/FSharp.AWS.DynamoDB/Script.fsx index 711958a..39f8901 100644 --- a/src/FSharp.AWS.DynamoDB/Script.fsx +++ b/src/FSharp.AWS.DynamoDB/Script.fsx @@ -205,9 +205,7 @@ type SimpleCounters private (table: TableContext) = member _.StartCounter() : Async = Counter.Start table -let e = - EasyCounters.Create(ddb, "testing") - |> Async.RunSynchronously +let e = EasyCounters.Create(ddb, "testing") |> Async.RunSynchronously let e1 = e.StartCounter() |> Async.RunSynchronously let e2 = e.StartCounter() |> Async.RunSynchronously @@ -215,8 +213,7 @@ e1.Incr() |> Async.RunSynchronously e2.Incr() |> Async.RunSynchronously // First, we create it in On-Demand mode -SimpleCounters.ProvisionOnDemand(ddb, "testing-pre-provisioned") -|> Async.RunSynchronously +SimpleCounters.ProvisionOnDemand(ddb, "testing-pre-provisioned") |> Async.RunSynchronously // Then we flip it to Provisioned mode SimpleCounters.Provision(ddb, "testing-pre-provisioned", readCapacityUnits = 10L, writeCapacityUnits = 10L) |> Async.RunSynchronously @@ -227,9 +224,7 @@ let s1 = s.StartCounter() |> Async.RunSynchronously // Throws if Provision step s1.Incr() |> Async.RunSynchronously // Alternately, we can have the app do an extra call (and have some asynchronous initialization work) to check the table is ready -let v = - SimpleCounters.CreateWithVerify(ddb, "testing-not-present") - |> Async.RunSynchronously // Throws, as table not present +let v = SimpleCounters.CreateWithVerify(ddb, "testing-not-present") |> Async.RunSynchronously // Throws, as table not present let v2 = v.StartCounter() |> Async.RunSynchronously v2.Incr() |> Async.RunSynchronously diff --git a/src/FSharp.AWS.DynamoDB/TableContext.fs b/src/FSharp.AWS.DynamoDB/TableContext.fs index 9a04692..ae3a230 100644 --- a/src/FSharp.AWS.DynamoDB/TableContext.fs +++ b/src/FSharp.AWS.DynamoDB/TableContext.fs @@ -91,11 +91,9 @@ module internal CreateTableRequest = let req = CreateTableRequest(TableName = tableName) template.Info.Schemata.ApplyToCreateTableRequest req // NOTE needs to precede the throughput application as that walks the GSIs list - throughput - |> Option.iter (Throughput.applyToCreateRequest req) // NOTE needs to succeed Schemata.ApplyToCreateTableRequest + throughput |> Option.iter (Throughput.applyToCreateRequest req) // NOTE needs to succeed Schemata.ApplyToCreateTableRequest - streaming - |> Option.iter (Streaming.applyToCreateRequest req) + streaming |> Option.iter (Streaming.applyToCreateRequest req) customize |> Option.iter (fun c -> c req) req @@ -104,9 +102,7 @@ module internal CreateTableRequest = async { let! ct = Async.CancellationToken - return! - client.CreateTableAsync(request, ct) - |> Async.AwaitTaskCorrect + return! client.CreateTableAsync(request, ct) |> Async.AwaitTaskCorrect } module internal UpdateTableRequest = @@ -114,23 +110,17 @@ module internal UpdateTableRequest = let create tableName = UpdateTableRequest(TableName = tableName) let apply throughput streaming request = - throughput - |> Option.iter (Throughput.applyToUpdateRequest request) + throughput |> Option.iter (Throughput.applyToUpdateRequest request) - streaming - |> Option.iter (Streaming.applyToUpdateRequest request) + streaming |> Option.iter (Streaming.applyToUpdateRequest request) // Yields a request only if throughput, streaming or customize determine the update is warranted let createIfRequired tableName tableDescription throughput streaming customize : UpdateTableRequest option = let request = create tableName - let tc = - throughput - |> Option.filter (Throughput.requiresUpdate tableDescription) + let tc = throughput |> Option.filter (Throughput.requiresUpdate tableDescription) - let sc = - streaming - |> Option.filter (Streaming.requiresUpdate tableDescription) + let sc = streaming |> Option.filter (Streaming.requiresUpdate tableDescription) match tc, sc, customize with | None, None, None -> None @@ -146,9 +136,7 @@ module internal UpdateTableRequest = async { let! ct = Async.CancellationToken - let! response = - client.UpdateTableAsync(request, ct) - |> Async.AwaitTaskCorrect + let! response = client.UpdateTableAsync(request, ct) |> Async.AwaitTaskCorrect return response.TableDescription } @@ -159,9 +147,7 @@ module internal Provisioning = async { let! ct = Async.CancellationToken - let! td = - client.DescribeTableAsync(tableName, ct) - |> Async.AwaitTaskCorrect + let! td = client.DescribeTableAsync(tableName, ct) |> Async.AwaitTaskCorrect return match td.Table with @@ -319,8 +305,7 @@ module TransactWriteItemsRequest = let writer = AttributeWriter(req.ExpressionAttributeNames, req.ExpressionAttributeValues) req.UpdateExpression <- updater.UpdateOps.Write(writer) - maybeCond - |> Option.iter (fun cond -> req.ConditionExpression <- cond.Conditional.Write writer) + maybeCond |> Option.iter (fun cond -> req.ConditionExpression <- cond.Conditional.Write writer) TransactWriteItem(Update = req) | TransactWrite.Delete(key, maybeCond) -> @@ -334,8 +319,7 @@ module TransactWriteItemsRequest = TransactWriteItem(Delete = req) let internal toTransactItems<'TRecord> tableName template items = - Seq.map (toTransactWriteItem<'TRecord> tableName template) items - |> rlist + Seq.map (toTransactWriteItem<'TRecord> tableName template) items |> rlist /// Exception filter to identify whether a TransactWriteItems call has failed due to /// one or more of the supplied precondition checks failing. @@ -404,10 +388,7 @@ type TableContext<'TRecord> async { match! tryGetItemAsync key consistentRead proj with | Some item -> return item - | None -> - return - raise - <| ResourceNotFoundException(sprintf "could not find item %O" key) + | None -> return raise <| ResourceNotFoundException(sprintf "could not find item %O" key) } let batchGetItemsAsync (keys: seq) (consistentRead: bool option) (projExpr: ProjectionExpr.ProjectionExpr option) = @@ -430,9 +411,7 @@ type TableContext<'TRecord> let! ct = Async.CancellationToken - let! response = - client.BatchGetItemAsync(request, ct) - |> Async.AwaitTaskCorrect + let! response = client.BatchGetItemAsync(request, ct) |> Async.AwaitTaskCorrect maybeReport |> Option.iter (fun r -> r BatchGetItems (List.ofSeq response.ConsumedCapacity) response.Responses[tableName].Count) @@ -469,9 +448,7 @@ type TableContext<'TRecord> let downloaded = ResizeArray<_>() let consumedCapacity = ResizeArray() - let emitMetrics () = - maybeReport - |> Option.iter (fun r -> r Query (Seq.toList consumedCapacity) downloaded.Count) + let emitMetrics () = maybeReport |> Option.iter (fun r -> r Query (Seq.toList consumedCapacity) downloaded.Count) let mutable lastEvaluatedKey: Dictionary option = None @@ -479,8 +456,7 @@ type TableContext<'TRecord> async { let request = QueryRequest(tableName, ReturnConsumedCapacity = returnConsumedCapacity) - keyCondition.IndexName - |> Option.iter (fun name -> request.IndexName <- name) + keyCondition.IndexName |> Option.iter (fun name -> request.IndexName <- name) let writer = AttributeWriter(request.ExpressionAttributeNames, request.ExpressionAttributeValues) request.KeyConditionExpression <- keyCondition.Write writer @@ -493,17 +469,13 @@ type TableContext<'TRecord> | None -> () | Some pe -> request.ProjectionExpression <- pe.Write writer - limit.GetCount() - |> Option.iter (fun l -> request.Limit <- l - downloaded.Count) + limit.GetCount() |> Option.iter (fun l -> request.Limit <- l - downloaded.Count) - consistentRead - |> Option.iter (fun cr -> request.ConsistentRead <- cr) + consistentRead |> Option.iter (fun cr -> request.ConsistentRead <- cr) - scanIndexForward - |> Option.iter (fun sif -> request.ScanIndexForward <- sif) + scanIndexForward |> Option.iter (fun sif -> request.ScanIndexForward <- sif) - last - |> Option.iter (fun l -> request.ExclusiveStartKey <- l) + last |> Option.iter (fun l -> request.ExclusiveStartKey <- l) let! ct = Async.CancellationToken let! response = client.QueryAsync(request, ct) |> Async.AwaitTaskCorrect @@ -573,9 +545,7 @@ type TableContext<'TRecord> let downloaded = ResizeArray<_>() let consumedCapacity = ResizeArray() - let emitMetrics () = - maybeReport - |> Option.iter (fun r -> r Scan (Seq.toList consumedCapacity) downloaded.Count) + let emitMetrics () = maybeReport |> Option.iter (fun r -> r Scan (Seq.toList consumedCapacity) downloaded.Count) let mutable lastEvaluatedKey: Dictionary option = None @@ -592,14 +562,11 @@ type TableContext<'TRecord> | None -> () | Some pe -> request.ProjectionExpression <- pe.Write writer - limit.GetCount() - |> Option.iter (fun l -> request.Limit <- l - downloaded.Count) + limit.GetCount() |> Option.iter (fun l -> request.Limit <- l - downloaded.Count) - consistentRead - |> Option.iter (fun cr -> request.ConsistentRead <- cr) + consistentRead |> Option.iter (fun cr -> request.ConsistentRead <- cr) - last - |> Option.iter (fun l -> request.ExclusiveStartKey <- l) + last |> Option.iter (fun l -> request.ExclusiveStartKey <- l) let! ct = Async.CancellationToken let! response = client.ScanAsync(request, ct) |> Async.AwaitTaskCorrect @@ -703,8 +670,7 @@ type TableContext<'TRecord> let! ct = Async.CancellationToken let! response = client.PutItemAsync(request, ct) |> Async.AwaitTaskCorrect - maybeReport - |> Option.iter (fun r -> r PutItem [ response.ConsumedCapacity ] 1) + maybeReport |> Option.iter (fun r -> r PutItem [ response.ConsumedCapacity ] 1) if response.HttpStatusCode <> HttpStatusCode.OK then failwithf "PutItem request returned error %O" response.HttpStatusCode @@ -741,9 +707,7 @@ type TableContext<'TRecord> pbr.RequestItems[tableName] <- writeRequests let! ct = Async.CancellationToken - let! response = - client.BatchWriteItemAsync(pbr, ct) - |> Async.AwaitTaskCorrect + let! response = client.BatchWriteItemAsync(pbr, ct) |> Async.AwaitTaskCorrect let unprocessed = match response.UnprocessedItems.TryGetValue tableName with @@ -798,12 +762,9 @@ type TableContext<'TRecord> let! ct = Async.CancellationToken - let! response = - client.UpdateItemAsync(request, ct) - |> Async.AwaitTaskCorrect + let! response = client.UpdateItemAsync(request, ct) |> Async.AwaitTaskCorrect - maybeReport - |> Option.iter (fun r -> r UpdateItem [ response.ConsumedCapacity ] 1) + maybeReport |> Option.iter (fun r -> r UpdateItem [ response.ConsumedCapacity ] 1) if response.HttpStatusCode <> HttpStatusCode.OK then failwithf "UpdateItem request returned error %O" response.HttpStatusCode @@ -825,9 +786,7 @@ type TableContext<'TRecord> ) = let updater = template.PrecomputeUpdateExpr updateExpr - let precondition = - precondition - |> Option.map template.PrecomputeConditionalExpr + let precondition = precondition |> Option.map template.PrecomputeConditionalExpr t.UpdateItemAsync(key, updater, ?returnLatest = returnLatest, ?precondition = precondition) @@ -845,9 +804,7 @@ type TableContext<'TRecord> ) = let updater = template.PrecomputeUpdateExpr updateExpr - let precondition = - precondition - |> Option.map template.PrecomputeConditionalExpr + let precondition = precondition |> Option.map template.PrecomputeConditionalExpr t.UpdateItemAsync(key, updater, ?returnLatest = returnLatest, ?precondition = precondition) @@ -877,8 +834,7 @@ type TableContext<'TRecord> let! ct = Async.CancellationToken let! response = client.GetItemAsync(request, ct) |> Async.AwaitTaskCorrect - maybeReport - |> Option.iter (fun r -> r GetItem [ response.ConsumedCapacity ] 1) + maybeReport |> Option.iter (fun r -> r GetItem [ response.ConsumedCapacity ] 1) return response.IsItemSet } @@ -937,10 +893,7 @@ type TableContext<'TRecord> async { let! response = batchGetItemsAsync keys consistentRead None - return - response - |> Seq.map template.OfAttributeValues - |> Seq.toArray + return response |> Seq.map template.OfAttributeValues |> Seq.toArray } @@ -997,12 +950,9 @@ type TableContext<'TRecord> let! ct = Async.CancellationToken - let! response = - client.DeleteItemAsync(request, ct) - |> Async.AwaitTaskCorrect + let! response = client.DeleteItemAsync(request, ct) |> Async.AwaitTaskCorrect - maybeReport - |> Option.iter (fun r -> r DeleteItem [ response.ConsumedCapacity ] 1) + maybeReport |> Option.iter (fun r -> r DeleteItem [ response.ConsumedCapacity ] 1) if response.HttpStatusCode <> HttpStatusCode.OK then failwithf "DeleteItem request returned error %O" response.HttpStatusCode @@ -1044,9 +994,7 @@ type TableContext<'TRecord> let! ct = Async.CancellationToken - let! response = - client.BatchWriteItemAsync(request, ct) - |> Async.AwaitTaskCorrect + let! response = client.BatchWriteItemAsync(request, ct) |> Async.AwaitTaskCorrect let unprocessed = match response.UnprocessedItems.TryGetValue tableName with @@ -1081,19 +1029,15 @@ type TableContext<'TRecord> let reqs = TransactWriteItemsRequest.toTransactItems tableName template items if reqs.Count = 0 || reqs.Count > 100 then - raise - <| System.ArgumentOutOfRangeException(nameof items, "must be between 1 and 100 items.") + raise <| System.ArgumentOutOfRangeException(nameof items, "must be between 1 and 100 items.") let req = TransactWriteItemsRequest(ReturnConsumedCapacity = returnConsumedCapacity, TransactItems = reqs) - clientRequestToken - |> Option.iter (fun x -> req.ClientRequestToken <- x) + clientRequestToken |> Option.iter (fun x -> req.ClientRequestToken <- x) let! ct = Async.CancellationToken - let! response = - client.TransactWriteItemsAsync(req, ct) - |> Async.AwaitTaskCorrect + let! response = client.TransactWriteItemsAsync(req, ct) |> Async.AwaitTaskCorrect maybeReport |> Option.iter (fun r -> r TransactWriteItems (Seq.toList response.ConsumedCapacity) reqs.Count) @@ -1124,10 +1068,7 @@ type TableContext<'TRecord> let filterCondition = filterCondition |> Option.map (fun fc -> fc.Conditional) let! downloaded = queryAsync keyCondition.Conditional filterCondition None limit consistentRead scanIndexForward - return - downloaded - |> Seq.map template.OfAttributeValues - |> Seq.toArray + return downloaded |> Seq.map template.OfAttributeValues |> Seq.toArray } /// @@ -1149,9 +1090,7 @@ type TableContext<'TRecord> let kc = template.PrecomputeConditionalExpr keyCondition - let fc = - filterCondition - |> Option.map template.PrecomputeConditionalExpr + let fc = filterCondition |> Option.map template.PrecomputeConditionalExpr t.QueryAsync(kc, ?filterCondition = fc, ?limit = limit, ?consistentRead = consistentRead, ?scanIndexForward = scanIndexForward) @@ -1204,9 +1143,7 @@ type TableContext<'TRecord> ?scanIndexForward: bool ) : Async<'TProjection[]> = - let filterCondition = - filterCondition - |> Option.map template.PrecomputeConditionalExpr + let filterCondition = filterCondition |> Option.map template.PrecomputeConditionalExpr t.QueryProjectedAsync( template.PrecomputeConditionalExpr keyCondition, @@ -1251,10 +1188,7 @@ type TableContext<'TRecord> scanIndexForward return - { Records = - downloaded - |> Seq.map template.OfAttributeValues - |> Seq.toArray + { Records = downloaded |> Seq.map template.OfAttributeValues |> Seq.toArray LastEvaluatedKey = lastEvaluatedKey } } @@ -1278,9 +1212,7 @@ type TableContext<'TRecord> ) : Async> = let kc = template.PrecomputeConditionalExpr keyCondition - let fc = - filterCondition - |> Option.map template.PrecomputeConditionalExpr + let fc = filterCondition |> Option.map template.PrecomputeConditionalExpr t.QueryPaginatedAsync( kc, @@ -1355,9 +1287,7 @@ type TableContext<'TRecord> ?consistentRead: bool, ?scanIndexForward: bool ) : Async> = - let filterCondition = - filterCondition - |> Option.map template.PrecomputeConditionalExpr + let filterCondition = filterCondition |> Option.map template.PrecomputeConditionalExpr t.QueryProjectedPaginatedAsync( template.PrecomputeConditionalExpr keyCondition, @@ -1381,10 +1311,7 @@ type TableContext<'TRecord> let filterCondition = filterCondition |> Option.map (fun fc -> fc.Conditional) let! downloaded = scanAsync filterCondition None limit consistentRead - return - downloaded - |> Seq.map template.OfAttributeValues - |> Seq.toArray + return downloaded |> Seq.map template.OfAttributeValues |> Seq.toArray } /// @@ -1436,9 +1363,7 @@ type TableContext<'TRecord> ?limit: int, ?consistentRead: bool ) : Async<'TProjection[]> = - let filterCondition = - filterCondition - |> Option.map template.PrecomputeConditionalExpr + let filterCondition = filterCondition |> Option.map template.PrecomputeConditionalExpr t.ScanProjectedAsync( template.PrecomputeProjectionExpr projection, @@ -1469,10 +1394,7 @@ type TableContext<'TRecord> scanPaginatedAsync filterCondition None (LimitType.DefaultOrCount limit) exclusiveStartKey consistentRead return - { Records = - downloaded - |> Seq.map template.OfAttributeValues - |> Seq.toArray + { Records = downloaded |> Seq.map template.OfAttributeValues |> Seq.toArray LastEvaluatedKey = lastEvaluatedKey } } @@ -1546,9 +1468,7 @@ type TableContext<'TRecord> ?exclusiveStartKey: TableKey, ?consistentRead: bool ) : Async> = - let filterCondition = - filterCondition - |> Option.map template.PrecomputeConditionalExpr + let filterCondition = filterCondition |> Option.map template.PrecomputeConditionalExpr t.ScanProjectedPaginatedAsync( template.PrecomputeProjectionExpr projection, @@ -1610,8 +1530,7 @@ type TableContext<'TRecord> /// Provisioned throughput to use on table. [] member t.UpdateProvisionedThroughputAsync(provisionedThroughput: ProvisionedThroughput) : Async = - t.UpdateTableIfRequiredAsync(Throughput.Provisioned provisionedThroughput) - |> Async.Ignore + t.UpdateTableIfRequiredAsync(Throughput.Provisioned provisionedThroughput) |> Async.Ignore /// Asynchronously verify that the table exists and is compatible with record key schema. /// Create the table instance now instance if it does not exist. Defaults to false. @@ -1624,8 +1543,7 @@ type TableContext<'TRecord> | Some p -> p | None -> ProvisionedThroughput(10L, 10L) - t.VerifyOrCreateTableAsync(Throughput.Provisioned throughput) - |> Async.Ignore + t.VerifyOrCreateTableAsync(Throughput.Provisioned throughput) |> Async.Ignore else t.VerifyTableAsync() @@ -1652,9 +1570,7 @@ type TableContext internal () = | Some p -> p | None -> ProvisionedThroughput(10L, 10L) - do! - context.VerifyOrCreateTableAsync(Throughput.Provisioned throughput) - |> Async.Ignore + do! context.VerifyOrCreateTableAsync(Throughput.Provisioned throughput) |> Async.Ignore elif verifyTable <> Some false then do! context.VerifyTableAsync() @@ -1752,9 +1668,7 @@ module Scripting = static member Initialize<'TRecord>(client: IAmazonDynamoDB, tableName: string, throughput) : TableContext<'TRecord> = let context = TableContext<'TRecord>(client, tableName) - let _desc = - context.VerifyOrCreateTableAsync(throughput) - |> Async.RunSynchronously + let _desc = context.VerifyOrCreateTableAsync(throughput) |> Async.RunSynchronously context @@ -1766,8 +1680,7 @@ module Scripting = /// Item to be written. /// Precondition to satisfy where item already exists. Use Precondition.CheckFailed to identify Precondition Check failures. member t.PutItem(item: 'TRecord, ?precondition: ConditionExpression<'TRecord>) = - t.PutItemAsync(item, ?precondition = precondition) - |> Async.RunSynchronously + t.PutItemAsync(item, ?precondition = precondition) |> Async.RunSynchronously /// /// Puts a record item in the table. @@ -1860,8 +1773,7 @@ module Scripting = /// Key of item to be fetched. /// Projection expression to be applied to item. member t.GetItemProjected(key: TableKey, projection: ProjectionExpression<'TRecord, 'TProjection>) : 'TProjection = - t.GetItemProjectedAsync(key, projection) - |> Async.RunSynchronously + t.GetItemProjectedAsync(key, projection) |> Async.RunSynchronously /// /// Fetches item of given key from table. @@ -1881,8 +1793,7 @@ module Scripting = /// Keys of items to be fetched. /// Perform consistent read. Defaults to false. member t.BatchGetItems(keys: seq, ?consistentRead: bool) = - t.BatchGetItemsAsync(keys, ?consistentRead = consistentRead) - |> Async.RunSynchronously + t.BatchGetItemsAsync(keys, ?consistentRead = consistentRead) |> Async.RunSynchronously /// @@ -1920,8 +1831,7 @@ module Scripting = /// Key of item to be deleted. /// Precondition to satisfy where item exists. Use Precondition.CheckFailed to identify Precondition Check failures. member t.DeleteItem(key: TableKey, ?precondition: ConditionExpression<'TRecord>) = - t.DeleteItemAsync(key, ?precondition = precondition) - |> Async.RunSynchronously + t.DeleteItemAsync(key, ?precondition = precondition) |> Async.RunSynchronously /// /// Deletes item of given key from table. @@ -1929,8 +1839,7 @@ module Scripting = /// Key of item to be deleted. /// Precondition to satisfy where item exists. Use Precondition.CheckFailed to identify Precondition Check failures. member t.DeleteItem(key: TableKey, precondition: Expr<'TRecord -> bool>) = - t.DeleteItemAsync(key, precondition) - |> Async.RunSynchronously + t.DeleteItemAsync(key, precondition) |> Async.RunSynchronously /// @@ -2337,6 +2246,4 @@ module Scripting = member t.UpdateProvisionedThroughput(provisionedThroughput: ProvisionedThroughput) : unit = let spec = Throughput.Provisioned provisionedThroughput - t.UpdateTableIfRequiredAsync(spec) - |> Async.Ignore - |> Async.RunSynchronously + t.UpdateTableIfRequiredAsync(spec) |> Async.Ignore |> Async.RunSynchronously diff --git a/src/FSharp.AWS.DynamoDB/Types.fs b/src/FSharp.AWS.DynamoDB/Types.fs index 05d761d..fdd9687 100644 --- a/src/FSharp.AWS.DynamoDB/Types.fs +++ b/src/FSharp.AWS.DynamoDB/Types.fs @@ -205,10 +205,7 @@ type IndexKey private (hashKey: obj, rangeKey: obj, primaryKey: TableKey) = override _.Equals o = match o with - | :? IndexKey as qk' -> - hashKey = qk'.HashKey - && rangeKey = qk'.RangeKey - && primaryKey = qk'.PrimaryKey + | :? IndexKey as qk' -> hashKey = qk'.HashKey && rangeKey = qk'.RangeKey && primaryKey = qk'.PrimaryKey | _ -> false override _.GetHashCode() = hash3 hashKey rangeKey primaryKey diff --git a/src/FSharp.AWS.DynamoDB/Utils/DynamoUtils.fs b/src/FSharp.AWS.DynamoDB/Utils/DynamoUtils.fs index db261a9..d94a009 100644 --- a/src/FSharp.AWS.DynamoDB/Utils/DynamoUtils.fs +++ b/src/FSharp.AWS.DynamoDB/Utils/DynamoUtils.fs @@ -43,13 +43,9 @@ type AttributeValueComparer() = elif av.NS.Count > 0 then av'.NS.Count > 0 && areEqualResizeArrays av.NS av'.NS elif av.BS.Count > 0 then - av'.BS.Count > 0 - && av.BS.Count = av'.BS.Count - && Seq.forall2 areEqualMemoryStreams av.BS av'.BS + av'.BS.Count > 0 && av.BS.Count = av'.BS.Count && Seq.forall2 areEqualMemoryStreams av.BS av'.BS elif av.IsLSet then - av'.IsLSet - && av.L.Count = av'.L.Count - && Seq.forall2 areEqualAttributeValues av.L av'.L + av'.IsLSet && av.L.Count = av'.L.Count && Seq.forall2 areEqualAttributeValues av.L av'.L elif av.IsMSet then av'.IsMSet && av.M.Count = av'.M.Count @@ -89,8 +85,7 @@ type AttributeValueComparer() = elif av.IsLSet then getSeqHash getAttributeValueHashCode av.L elif av.IsMSet then - av.M - |> getSeqHash (fun kv -> hash2 kv.Key (getAttributeValueHashCode kv.Value)) + av.M |> getSeqHash (fun kv -> hash2 kv.Key (getAttributeValueHashCode kv.Value)) else -1 @@ -138,22 +133,13 @@ type AttributeValue with elif av.NS.Count > 0 then sprintf "{ SN = %A }" (Seq.toArray av.NS) elif av.BS.Count > 0 then - av.BS - |> Seq.map (fun bs -> bs.ToArray()) - |> Seq.toArray - |> sprintf "{ BS = %A }" + av.BS |> Seq.map (fun bs -> bs.ToArray()) |> Seq.toArray |> sprintf "{ BS = %A }" elif av.IsLSet then - av.L - |> Seq.map (fun av -> av.Print()) - |> Seq.toArray - |> sprintf "{ L = %A }" + av.L |> Seq.map (fun av -> av.Print()) |> Seq.toArray |> sprintf "{ L = %A }" elif av.IsMSet then - av.M - |> Seq.map (fun kv -> (kv.Key, kv.Value.Print())) - |> Seq.toArray - |> sprintf "{ M = %A }" + av.M |> Seq.map (fun kv -> (kv.Key, kv.Value.Print())) |> Seq.toArray |> sprintf "{ M = %A }" else "{ }" diff --git a/src/FSharp.AWS.DynamoDB/Utils/Utils.fs b/src/FSharp.AWS.DynamoDB/Utils/Utils.fs index 5c21de9..8172c2d 100644 --- a/src/FSharp.AWS.DynamoDB/Utils/Utils.fs +++ b/src/FSharp.AWS.DynamoDB/Utils/Utils.fs @@ -72,19 +72,13 @@ module internal Utils = type MemberInfo with member m.TryGetAttribute<'Attribute when 'Attribute :> Attribute>() : 'Attribute option = - m.GetCustomAttributes(true) - |> Seq.map unbox - |> tryGetAttribute + m.GetCustomAttributes(true) |> Seq.map unbox |> tryGetAttribute member m.GetAttributes<'Attribute when 'Attribute :> Attribute>() : 'Attribute[] = - m.GetCustomAttributes(true) - |> Seq.map unbox - |> getAttributes + m.GetCustomAttributes(true) |> Seq.map unbox |> getAttributes member m.ContainsAttribute<'Attribute when 'Attribute :> Attribute>() : bool = - m.GetCustomAttributes(true) - |> Seq.map unbox - |> containsAttribute + m.GetCustomAttributes(true) |> Seq.map unbox |> containsAttribute type MethodInfo with @@ -239,10 +233,7 @@ module internal Utils = | NewUnionCase(uci, [ h; t ]) -> let dt = uci.DeclaringType - if - dt.IsGenericType - && dt.GetGenericTypeDefinition() = typedefof<_ list> - then + if dt.IsGenericType && dt.GetGenericTypeDefinition() = typedefof<_ list> then Some(h, t) else None diff --git a/tests/FSharp.AWS.DynamoDB.Tests/ConditionalExpressionTests.fs b/tests/FSharp.AWS.DynamoDB.Tests/ConditionalExpressionTests.fs index b73ea24..8c2444c 100644 --- a/tests/FSharp.AWS.DynamoDB.Tests/ConditionalExpressionTests.fs +++ b/tests/FSharp.AWS.DynamoDB.Tests/ConditionalExpressionTests.fs @@ -88,9 +88,7 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = LSI = rand () GSIH = guid () GSIR = int (rand ()) - Map = - seq { for _ in 0L .. rand () % 5L -> "K" + guid (), rand () } - |> Map.ofSeq + Map = seq { for _ in 0L .. rand () % 5L -> "K" + guid (), rand () } |> Map.ofSeq Set = seq { for _ in 0L .. rand () % 5L -> rand () } |> Set.ofSeq List = [ for _ in 0L .. rand () % 5L -> rand () ] Array = [| for _ in 0L .. rand () % 5L -> rand () |] @@ -122,10 +120,7 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = let _key = table.PutItem(item, precondition = itemDoesNotExist) raisesWith - <@ - table.PutItemAsync(item, precondition = itemDoesNotExist) - |> Async.RunSynchronously - @> + <@ table.PutItemAsync(item, precondition = itemDoesNotExist) |> Async.RunSynchronously @> (fun e -> <@ e.Item.Count > 0 @>) [] @@ -184,14 +179,7 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = let _value = item.DateTimeOffset - table.PutItem( - item, - <@ - fun r -> - r.DateTimeOffset - <= DateTimeOffset.Now + TimeSpan.FromDays(3.) - @> - ) + table.PutItem(item, <@ fun r -> r.DateTimeOffset <= DateTimeOffset.Now + TimeSpan.FromDays(3.) @>) =! _key [] @@ -227,8 +215,7 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = |> shouldFailwith<_, ConditionalCheckFailedException> - table.PutItem(item, <@ fun r -> r.Guid <> Guid.NewGuid() @>) - =! _key + table.PutItem(item, <@ fun r -> r.Guid <> Guid.NewGuid() @>) =! _key [] let ``Optional precondition`` () = @@ -240,8 +227,7 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = let value = item.Optional - table.PutItem({ item with Optional = None }, <@ fun r -> r.Optional = value @>) - =! _key + table.PutItem({ item with Optional = None }, <@ fun r -> r.Optional = value @>) =! _key fun () -> table.PutItem(item, <@ fun r -> r.Optional = (guid () |> Some) @>) |> shouldFailwith<_, ConditionalCheckFailedException> @@ -270,8 +256,7 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = let value = item.Ref.Value - table.PutItem(item, <@ fun r -> r.Ref = ref value @>) - =! _key + table.PutItem(item, <@ fun r -> r.Ref = ref value @>) =! _key [] let ``Tuple precondition`` () = @@ -283,8 +268,7 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = let value = fst item.Tuple - table.PutItem(item, <@ fun r -> fst r.Tuple = value @>) - =! _key + table.PutItem(item, <@ fun r -> fst r.Tuple = value @>) =! _key [] let ``Record precondition`` () = @@ -297,8 +281,7 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = let value = item.Nested.NV let enum = item.Nested.NE - table.PutItem(item, <@ fun r -> r.Nested = { NV = value; NE = enum } @>) - =! _key + table.PutItem(item, <@ fun r -> r.Nested = { NV = value; NE = enum } @>) =! _key [] let ``Nested attribute precondition`` () = @@ -310,8 +293,7 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = let value = item.Nested.NE - table.PutItem(item, <@ fun r -> r.Nested.NE = value @>) - =! _key + table.PutItem(item, <@ fun r -> r.Nested.NE = value @>) =! _key [] let ``Nested union precondition`` () = @@ -321,8 +303,7 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = fun () -> table.PutItem(item, <@ fun r -> r.Union = UA(rand ()) @>) |> shouldFailwith<_, ConditionalCheckFailedException> - table.PutItem(item, <@ fun r -> r.Union = item.Union @>) - =! _key + table.PutItem(item, <@ fun r -> r.Union = item.Union @>) =! _key [] let ``String-Contains precondition`` () = @@ -332,8 +313,7 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = fun () -> table.PutItem(item, <@ fun r -> r.Ref.Value.Contains "41" @>) |> shouldFailwith<_, ConditionalCheckFailedException> - table.PutItem(item, <@ fun r -> r.Ref.Value.Contains "42" @>) - =! _key + table.PutItem(item, <@ fun r -> r.Ref.Value.Contains "42" @>) =! _key [] let ``String-StartsWith precondition`` () = @@ -343,8 +323,7 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = fun () -> table.PutItem(item, <@ fun r -> r.Ref.Value.StartsWith "41" @>) |> shouldFailwith<_, ConditionalCheckFailedException> - table.PutItem(item, <@ fun r -> r.Ref.Value.StartsWith "12" @>) - =! _key + table.PutItem(item, <@ fun r -> r.Ref.Value.StartsWith "12" @>) =! _key [] let ``String-length precondition`` () = @@ -355,8 +334,7 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = fun () -> table.PutItem(item, <@ fun r -> r.HashKey.Length <> elem.Length @>) |> shouldFailwith<_, ConditionalCheckFailedException> - table.PutItem(item, <@ fun r -> r.HashKey.Length >= elem.Length @>) - =! _key + table.PutItem(item, <@ fun r -> r.HashKey.Length >= elem.Length @>) =! _key [] @@ -368,11 +346,9 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = fun () -> table.PutItem(item, <@ fun r -> r.Bytes.Length <> bytes.Length @>) |> shouldFailwith<_, ConditionalCheckFailedException> - table.PutItem(item, <@ fun r -> r.Bytes.Length >= bytes.Length @>) - =! _key + table.PutItem(item, <@ fun r -> r.Bytes.Length >= bytes.Length @>) =! _key - table.PutItem(item, <@ fun r -> r.Bytes |> Array.length >= bytes.Length @>) - =! _key + table.PutItem(item, <@ fun r -> r.Bytes |> Array.length >= bytes.Length @>) =! _key [] let ``Array index precondition`` () = @@ -383,8 +359,7 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = fun () -> table.PutItem(item, <@ fun r -> r.NestedList[0].NV = guid () @>) |> shouldFailwith<_, ConditionalCheckFailedException> - table.PutItem(item, <@ fun r -> r.NestedList[0] = nested @>) - =! _key + table.PutItem(item, <@ fun r -> r.NestedList[0] = nested @>) =! _key [] let ``List-length precondition`` () = @@ -395,19 +370,16 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = fun () -> table.PutItem(item, <@ fun r -> r.List.Length <> list.Length @>) |> shouldFailwith<_, ConditionalCheckFailedException> - table.PutItem(item, <@ fun r -> r.List.Length >= list.Length @>) - =! _key + table.PutItem(item, <@ fun r -> r.List.Length >= list.Length @>) =! _key - table.PutItem(item, <@ fun r -> List.length r.List >= list.Length @>) - =! _key + table.PutItem(item, <@ fun r -> List.length r.List >= list.Length @>) =! _key [] let ``List-isEmpty precondition`` () = let item = { mkItem () with List = [] } let _key = table.PutItem item - table.PutItem({ item with List = [ 42L ] }, <@ fun r -> List.isEmpty r.List @>) - =! _key + table.PutItem({ item with List = [ 42L ] }, <@ fun r -> List.isEmpty r.List @>) =! _key fun () -> table.PutItem(item, <@ fun r -> List.isEmpty r.List @>) |> shouldFailwith<_, ConditionalCheckFailedException> @@ -422,11 +394,9 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = fun () -> table.PutItem(item, <@ fun r -> r.Set.Count <> set.Count @>) |> shouldFailwith<_, ConditionalCheckFailedException> - table.PutItem(item, <@ fun r -> r.Set.Count <= set.Count @>) - =! _key + table.PutItem(item, <@ fun r -> r.Set.Count <= set.Count @>) =! _key - table.PutItem(item, <@ fun r -> r.Set |> Set.count >= Set.count set @>) - =! _key + table.PutItem(item, <@ fun r -> r.Set |> Set.count >= Set.count set @>) =! _key [] let ``Set-contains precondition`` () = @@ -437,11 +407,9 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = fun () -> table.PutItem(item, <@ fun r -> r.Set.Contains(elem + 1L) @>) |> shouldFailwith<_, ConditionalCheckFailedException> - table.PutItem(item, <@ fun r -> r.Set.Contains elem @>) - =! _key + table.PutItem(item, <@ fun r -> r.Set.Contains elem @>) =! _key - table.PutItem(item, <@ fun r -> r.Set |> Set.contains elem @>) - =! _key + table.PutItem(item, <@ fun r -> r.Set |> Set.contains elem @>) =! _key [] let ``Map-count precondition`` () = @@ -452,8 +420,7 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = fun () -> table.PutItem(item, <@ fun r -> r.Map.Count <> map.Count @>) |> shouldFailwith<_, ConditionalCheckFailedException> - table.PutItem(item, <@ fun r -> r.Map.Count >= map.Count @>) - =! _key + table.PutItem(item, <@ fun r -> r.Map.Count >= map.Count @>) =! _key [] let ``Map-contains precondition`` () = @@ -464,11 +431,9 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = fun () -> table.PutItem(item, <@ fun r -> r.Map.ContainsKey(elem + "foo") @>) |> shouldFailwith<_, ConditionalCheckFailedException> - table.PutItem(item, <@ fun r -> r.Map.ContainsKey elem @>) - =! _key + table.PutItem(item, <@ fun r -> r.Map.ContainsKey elem @>) =! _key - table.PutItem(item, <@ fun r -> r.Map |> Map.containsKey elem @>) - =! _key + table.PutItem(item, <@ fun r -> r.Map |> Map.containsKey elem @>) =! _key [] let ``Map Item precondition`` () = @@ -478,8 +443,7 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = fun () -> table.PutItem(item, <@ fun r -> r.Map["A"] = 41L @>) |> shouldFailwith<_, ConditionalCheckFailedException> - table.PutItem(item, <@ fun r -> r.Map["A"] = 42L @>) - |> ignore + table.PutItem(item, <@ fun r -> r.Map["A"] = 42L @>) |> ignore [] let ``Map Item parametric precondition`` () = @@ -526,23 +490,11 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = table.PutItem( item, - <@ - fun r -> - false - || r.HashKey = item.HashKey - && not (not (r.RangeKey = item.RangeKey || r.Bool = item.Bool)) - @> + <@ fun r -> false || r.HashKey = item.HashKey && not (not (r.RangeKey = item.RangeKey || r.Bool = item.Bool)) @> ) =! _key - table.PutItem( - item, - <@ - fun r -> - r.HashKey = item.HashKey - || (true && r.RangeKey = item.RangeKey) - @> - ) + table.PutItem(item, <@ fun r -> r.HashKey = item.HashKey || (true && r.RangeKey = item.RangeKey) @>) =! _key [] @@ -578,8 +530,7 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = [] let ``Detect incompatible key conditions`` () = - let test outcome q = - test <@ outcome = table.Template.PrecomputeConditionalExpr(q).IsKeyConditionCompatible @> + let test outcome q = test <@ outcome = table.Template.PrecomputeConditionalExpr(q).IsKeyConditionCompatible @> test true <@ fun r -> r.HashKey = "2" @> test true <@ fun r -> r.HashKey = "2" && r.RangeKey < 2L @> @@ -698,13 +649,7 @@ type ``Conditional Expression Tests``(fixture: TableFixture) = let _key = table.PutItem item - testScan - 1 - <@ - fun r -> - [| item.Value + 10L; item.Value - 10L; item.Value |] - |> Array.contains r.Value - @> + testScan 1 <@ fun r -> [| item.Value + 10L; item.Value - 10L; item.Value |] |> Array.contains r.Value @> testScan 1 <@ fun r -> elem |> Array.contains r.Value @> testScan 1 <@ fun r -> elemL |> List.contains r.Value @> diff --git a/tests/FSharp.AWS.DynamoDB.Tests/MetricsCollectorTests.fs b/tests/FSharp.AWS.DynamoDB.Tests/MetricsCollectorTests.fs index a8f7427..8ca66b8 100644 --- a/tests/FSharp.AWS.DynamoDB.Tests/MetricsCollectorTests.fs +++ b/tests/FSharp.AWS.DynamoDB.Tests/MetricsCollectorTests.fs @@ -259,11 +259,7 @@ type BulkMutationTests(fixture: TableFixture) = [] let ``Collect Metrics on BatchDeleteItem`` () = - let _keys = - sut.BatchDeleteItems( - items - |> Seq.map (fun i -> TableKey.Combined(i.HashKey, i.RangeKey)) - ) + let _keys = sut.BatchDeleteItems(items |> Seq.map (fun i -> TableKey.Combined(i.HashKey, i.RangeKey))) test <@ diff --git a/tests/FSharp.AWS.DynamoDB.Tests/MultipleKeyAttributeTests.fs b/tests/FSharp.AWS.DynamoDB.Tests/MultipleKeyAttributeTests.fs index 9525fdf..8a3a778 100644 --- a/tests/FSharp.AWS.DynamoDB.Tests/MultipleKeyAttributeTests.fs +++ b/tests/FSharp.AWS.DynamoDB.Tests/MultipleKeyAttributeTests.fs @@ -49,23 +49,11 @@ type ``Inverse GSI Table Operation Tests``(fixture: TableFixture) = let queriedTable = table.Query <@ fun (i: InverseKeyRecord) -> i.PrimaryKey = "1" && i.SortKey.StartsWith "2" @> - test - <@ - set queriedTable = set ( - values - |> Set.filter (fun i -> i.PrimaryKey = "1" && i.SortKey.StartsWith "2") - ) - @> + test <@ set queriedTable = set (values |> Set.filter (fun i -> i.PrimaryKey = "1" && i.SortKey.StartsWith "2")) @> let queriedGSI = table.Query <@ fun (i: InverseKeyRecord) -> i.SortKey = "1" && i.PrimaryKey.StartsWith "2" @> - test - <@ - set queriedGSI = set ( - values - |> Set.filter (fun i -> i.SortKey = "1" && i.PrimaryKey.StartsWith "2") - ) - @> + test <@ set queriedGSI = set (values |> Set.filter (fun i -> i.SortKey = "1" && i.PrimaryKey.StartsWith "2")) @> interface IClassFixture @@ -90,22 +78,10 @@ type ``Shared Range Key Table Operation Tests``(fixture: TableFixture) = let queried1 = table.Query <@ fun (i: SharedRangeKeyRecord) -> i.GSI1 = "1" && i.SortKey = "23" @> - test - <@ - set queried1 = set ( - values - |> Set.filter (fun i -> i.GSI1 = "1" && i.SortKey = "23") - ) - @> + test <@ set queried1 = set (values |> Set.filter (fun i -> i.GSI1 = "1" && i.SortKey = "23")) @> let queried2 = table.Query <@ fun (i: SharedRangeKeyRecord) -> i.GSI2 = "2" && i.SortKey = "25" @> - test - <@ - set queried2 = set ( - values - |> Set.filter (fun i -> i.GSI2 = "2" && i.SortKey = "25") - ) - @> + test <@ set queried2 = set (values |> Set.filter (fun i -> i.GSI2 = "2" && i.SortKey = "25")) @> interface IClassFixture diff --git a/tests/FSharp.AWS.DynamoDB.Tests/PaginationTests.fs b/tests/FSharp.AWS.DynamoDB.Tests/PaginationTests.fs index 33d5090..5b9f9d2 100644 --- a/tests/FSharp.AWS.DynamoDB.Tests/PaginationTests.fs +++ b/tests/FSharp.AWS.DynamoDB.Tests/PaginationTests.fs @@ -47,31 +47,18 @@ type ``Pagination Tests``(fixture: TableFixture) = let hk = guid () let gsk = guid () - let items = - seq { for _ in 0..9 -> mkItem hk gsk } - |> Seq.toArray - |> Array.sortBy (fun r -> r.RangeKey) + let items = seq { for _ in 0..9 -> mkItem hk gsk } |> Seq.toArray |> Array.sortBy (fun r -> r.RangeKey) for item in items do - table.PutItem item - =! TableKey.Combined(item.HashKey, item.RangeKey) + table.PutItem item =! TableKey.Combined(item.HashKey, item.RangeKey) let res1 = table.QueryPaginated(<@ fun r -> r.HashKey = hk @>, limit = 5) let res2 = table.QueryPaginated(<@ fun r -> r.HashKey = hk @>, limit = 5, ?exclusiveStartKey = res1.LastEvaluatedKey) let res3 = table.QueryPaginated(<@ fun r -> r.HashKey = hk @>, limit = 5, ?exclusiveStartKey = res2.LastEvaluatedKey) - test - <@ - None <> res1.LastEvaluatedKey - && None <> res2.LastEvaluatedKey - && None = res3.LastEvaluatedKey - @> + test <@ None <> res1.LastEvaluatedKey && None <> res2.LastEvaluatedKey && None = res3.LastEvaluatedKey @> - test - <@ - items = Array.append res1.Records res2.Records - && Array.isEmpty res3.Records - @> + test <@ items = Array.append res1.Records res2.Records && Array.isEmpty res3.Records @> [] let ``Paginated Query on LSI`` () = @@ -84,8 +71,7 @@ type ``Pagination Tests``(fixture: TableFixture) = |> Array.sortBy (fun r -> r.LocalSecondaryRangeKey) for item in items do - table.PutItem item - =! TableKey.Combined(item.HashKey, item.RangeKey) + table.PutItem item =! TableKey.Combined(item.HashKey, item.RangeKey) let res1 = table.QueryPaginated(<@ fun r -> r.HashKey = hk && r.LocalSecondaryRangeKey > "0" @>, limit = 5) @@ -103,71 +89,40 @@ type ``Pagination Tests``(fixture: TableFixture) = ?exclusiveStartKey = res2.LastEvaluatedKey ) - test - <@ - None <> res1.LastEvaluatedKey - && None <> res2.LastEvaluatedKey - && None = res3.LastEvaluatedKey - @> + test <@ None <> res1.LastEvaluatedKey && None <> res2.LastEvaluatedKey && None = res3.LastEvaluatedKey @> - test - <@ - items = Array.append res1.Records res2.Records - && Array.isEmpty res3.Records - @> + test <@ items = Array.append res1.Records res2.Records && Array.isEmpty res3.Records @> [] let ``Paginated Query on GSI`` () = let hk = guid () let gsk = guid () - let items = - seq { for _ in 0..9 -> mkItem hk gsk } - |> Seq.toArray - |> Array.sortBy (fun r -> r.SecondaryRangeKey) + let items = seq { for _ in 0..9 -> mkItem hk gsk } |> Seq.toArray |> Array.sortBy (fun r -> r.SecondaryRangeKey) for item in items do - table.PutItem item - =! TableKey.Combined(item.HashKey, item.RangeKey) + table.PutItem item =! TableKey.Combined(item.HashKey, item.RangeKey) let res1 = table.QueryPaginated(<@ fun r -> r.SecondaryHashKey = gsk @>, limit = 5) let res2 = table.QueryPaginated(<@ fun r -> r.SecondaryHashKey = gsk @>, limit = 5, ?exclusiveStartKey = res1.LastEvaluatedKey) let res3 = table.QueryPaginated(<@ fun r -> r.SecondaryHashKey = gsk @>, limit = 5, ?exclusiveStartKey = res2.LastEvaluatedKey) - test - <@ - None <> res1.LastEvaluatedKey - && None <> res2.LastEvaluatedKey - && None = res3.LastEvaluatedKey - @> + test <@ None <> res1.LastEvaluatedKey && None <> res2.LastEvaluatedKey && None = res3.LastEvaluatedKey @> - test - <@ - items = Array.append res1.Records res2.Records - && Array.isEmpty res3.Records - @> + test <@ items = Array.append res1.Records res2.Records && Array.isEmpty res3.Records @> [] let ``Paginated Query with filter`` () = let hk = guid () let gsk = guid () - let items = - seq { for _ in 0..49 -> mkItem hk gsk } - |> Seq.toArray - |> Array.sortBy (fun r -> r.RangeKey) + let items = seq { for _ in 0..49 -> mkItem hk gsk } |> Seq.toArray |> Array.sortBy (fun r -> r.RangeKey) for item in items do - table.PutItem item - =! TableKey.Combined(item.HashKey, item.RangeKey) + table.PutItem item =! TableKey.Combined(item.HashKey, item.RangeKey) let res = table.QueryPaginated(<@ fun r -> r.HashKey = hk @>, filterCondition = <@ fun r -> r.LocalAttribute = 0 @>, limit = 5) - test - <@ - items - |> Array.filter (fun r -> r.LocalAttribute = 0) - |> Array.take 5 = res.Records - @> + test <@ items |> Array.filter (fun r -> r.LocalAttribute = 0) |> Array.take 5 = res.Records @> interface IClassFixture diff --git a/tests/FSharp.AWS.DynamoDB.Tests/ProjectionExpressionTests.fs b/tests/FSharp.AWS.DynamoDB.Tests/ProjectionExpressionTests.fs index 9f6cf0d..58946af 100644 --- a/tests/FSharp.AWS.DynamoDB.Tests/ProjectionExpressionTests.fs +++ b/tests/FSharp.AWS.DynamoDB.Tests/ProjectionExpressionTests.fs @@ -92,9 +92,7 @@ type ``Projection Expression Tests``(fixture: TableFixture) = Bytes = Guid.NewGuid().ToByteArray() Nested = { NV = guid (); NE = enum (int (rand ()) % 3) } NestedList = [ { NV = guid (); NE = enum (int (rand ()) % 3) } ] - Map = - seq { for _ in 0L .. rand () % 5L -> "K" + guid (), rand () } - |> Map.ofSeq + Map = seq { for _ in 0L .. rand () % 5L -> "K" + guid (), rand () } |> Map.ofSeq IntSet = seq { for _ in 0L .. rand () % 5L -> rand () } |> Set.ofSeq StringSet = seq { for _ in 0L .. rand () % 5L -> guid () } |> Set.ofSeq ByteSet = seq { for _ in 0L .. rand () % 5L -> bytes () } |> Set.ofSeq diff --git a/tests/FSharp.AWS.DynamoDB.Tests/RecordGenerationTests.fs b/tests/FSharp.AWS.DynamoDB.Tests/RecordGenerationTests.fs index 62b853c..09922cd 100644 --- a/tests/FSharp.AWS.DynamoDB.Tests/RecordGenerationTests.fs +++ b/tests/FSharp.AWS.DynamoDB.Tests/RecordGenerationTests.fs @@ -35,8 +35,7 @@ module ``Record Generation Tests`` = // account for random inputs not supported by the library | :? InvalidOperationException as e when e.Message = "empty strings not supported by DynamoDB." -> () | :? ArgumentException as e when - e.Message.Contains "unsupported key name" - && e.Message.Contains "should be 1 to 64k long (as utf8)" + e.Message.Contains "unsupported key name" && e.Message.Contains "should be 1 to 64k long (as utf8)" -> () @@ -354,10 +353,7 @@ module ``Record Generation Tests`` = [] let ``Generated picklers should be singletons`` () = - let actual = - Array.Parallel.init 100 (fun _ -> Pickler.resolve ()) - |> Seq.distinct - |> Seq.length + let actual = Array.Parallel.init 100 (fun _ -> Pickler.resolve ()) |> Seq.distinct |> Seq.length test <@ 1 = actual @> @@ -597,9 +593,5 @@ module ``Record Generation Tests`` = let expectedDateTime, expectedOffset = d.DateTime, d.Offset let actualDateTime, actualOffset = d'.DateTime, d'.Offset - test - <@ - expectedDateTime = actualDateTime - && expectedOffset = actualOffset - @> + test <@ expectedDateTime = actualDateTime && expectedOffset = actualOffset @> ) diff --git a/tests/FSharp.AWS.DynamoDB.Tests/SimpleTableOperationTests.fs b/tests/FSharp.AWS.DynamoDB.Tests/SimpleTableOperationTests.fs index 9dc1d8e..6088aa3 100644 --- a/tests/FSharp.AWS.DynamoDB.Tests/SimpleTableOperationTests.fs +++ b/tests/FSharp.AWS.DynamoDB.Tests/SimpleTableOperationTests.fs @@ -49,9 +49,7 @@ type ``Simple Table Operation Tests``(fixture: TableFixture) = RangeKey = guid () Value = rand () Tuple = rand (), rand () - Map = - seq { for _ in 0L .. rand () % 5L -> "K" + guid (), rand () } - |> Map.ofSeq + Map = seq { for _ in 0L .. rand () % 5L -> "K" + guid (), rand () } |> Map.ofSeq Unions = [ Choice1Of3(guid ()); Choice2Of3(rand ()); Choice3Of3(Guid.NewGuid().ToByteArray()) ] } let table = fixture.CreateEmpty() @@ -101,10 +99,7 @@ type ``Simple Table Operation Tests``(fixture: TableFixture) = let unprocessed = table.BatchPutItems values let values' = - table.BatchGetItems( - values - |> Seq.map (fun r -> TableKey.Combined(r.HashKey, r.RangeKey)) - ) + table.BatchGetItems(values |> Seq.map (fun r -> TableKey.Combined(r.HashKey, r.RangeKey))) |> Set.ofArray test <@ Array.isEmpty unprocessed @> @@ -115,19 +110,11 @@ type ``Simple Table Operation Tests``(fixture: TableFixture) = let values = set [ for _ in 1L .. 20L -> mkItem () ] table.BatchPutItems values |> ignore - let unprocessed = - table.BatchDeleteItems( - values - |> Seq.map (fun r -> TableKey.Combined(r.HashKey, r.RangeKey)) - ) + let unprocessed = table.BatchDeleteItems(values |> Seq.map (fun r -> TableKey.Combined(r.HashKey, r.RangeKey))) test <@ Array.isEmpty unprocessed @> - let values' = - table.BatchGetItems( - values - |> Seq.map (fun r -> TableKey.Combined(r.HashKey, r.RangeKey)) - ) + let values' = table.BatchGetItems(values |> Seq.map (fun r -> TableKey.Combined(r.HashKey, r.RangeKey))) test <@ Array.isEmpty values' @> @@ -162,9 +149,7 @@ type ``TransactWriteItems tests``(fixture: TableFixture) = RangeKey = guid () Value = rand () Tuple = rand (), rand () - Map = - seq { for _ in 0L .. rand () % 5L -> "K" + guid (), rand () } - |> Map.ofSeq + Map = seq { for _ in 0L .. rand () % 5L -> "K" + guid (), rand () } |> Map.ofSeq Unions = [ Choice1Of3(guid ()); Choice2Of3(rand ()); Choice3Of3(Guid.NewGuid().ToByteArray()) ] } let table = fixture.CreateEmpty() @@ -262,11 +247,7 @@ type ``TransactWriteItems tests``(fixture: TableFixture) = let! maybeItem = table.TryGetItemAsync key - test - <@ - shouldFail - <> (maybeItem |> Option.contains { item with Value = 42 }) - @> + test <@ shouldFail <> (maybeItem |> Option.contains { item with Value = 42 }) @> let! maybeItem2 = table.TryGetItemAsync(table.Template.ExtractKey item2) test <@ shouldFail <> (maybeItem2 |> Option.contains item2) @> @@ -276,13 +257,7 @@ type ``TransactWriteItems tests``(fixture: TableFixture) = let! maybeItem7 = table.TryGetItemAsync(table.Template.ExtractKey item7) - test - <@ - shouldFail - <> (maybeItem7 - |> Option.map (fun x -> x.Tuple) - |> Option.contains (42, 42)) - @> + test <@ shouldFail <> (maybeItem7 |> Option.map (fun x -> x.Tuple) |> Option.contains (42, 42)) @> } let shouldBeRejectedWithArgumentOutOfRangeException requests = diff --git a/tests/FSharp.AWS.DynamoDB.Tests/SparseGSITests.fs b/tests/FSharp.AWS.DynamoDB.Tests/SparseGSITests.fs index f87df5e..ec26b12 100644 --- a/tests/FSharp.AWS.DynamoDB.Tests/SparseGSITests.fs +++ b/tests/FSharp.AWS.DynamoDB.Tests/SparseGSITests.fs @@ -50,8 +50,7 @@ type ``Sparse GSI Tests``(fixture: TableFixture) = let value = { mkItem () with SecondaryHashKey = Some(guid ()) } let key = table.PutItem value - table.UpdateItem(key, <@ fun r -> { r with SecondaryHashKey = None } @>) - |> ignore + table.UpdateItem(key, <@ fun r -> { r with SecondaryHashKey = None } @>) |> ignore let res = table.Query(keyCondition = <@ fun (r: GsiRecord) -> r.SecondaryHashKey = value.SecondaryHashKey @>) test <@ Array.isEmpty res @> diff --git a/tests/FSharp.AWS.DynamoDB.Tests/UpdateExpressionTests.fs b/tests/FSharp.AWS.DynamoDB.Tests/UpdateExpressionTests.fs index 35ee781..eeec746 100644 --- a/tests/FSharp.AWS.DynamoDB.Tests/UpdateExpressionTests.fs +++ b/tests/FSharp.AWS.DynamoDB.Tests/UpdateExpressionTests.fs @@ -89,9 +89,7 @@ type ``Update Expression Tests``(fixture: TableFixture) = Bytes = Guid.NewGuid().ToByteArray() Nested = { NV = guid (); NE = enum (int (rand ()) % 3) } NestedList = [ { NV = guid (); NE = enum (int (rand ()) % 3) } ] - Map = - seq { for _ in 0L .. rand () % 5L -> "K" + guid (), rand () } - |> Map.ofSeq + Map = seq { for _ in 0L .. rand () % 5L -> "K" + guid (), rand () } |> Map.ofSeq IntSet = seq { for _ in 0L .. rand () % 5L -> rand () } |> Set.ofSeq StringSet = seq { for _ in 0L .. rand () % 5L -> guid () } |> Set.ofSeq ByteSet = seq { for _ in 0L .. rand () % 5L -> bytes () } |> Set.ofSeq @@ -390,11 +388,7 @@ type ``Update Expression Tests``(fixture: TableFixture) = let item' = table.UpdateItem( key, - <@ - fun r -> - SET r.NestedList[0].NV item.HashKey - &&& SET r.NestedList[1] { NV = item.HashKey; NE = Enum.C } - @> + <@ fun r -> SET r.NestedList[0].NV item.HashKey &&& SET r.NestedList[1] { NV = item.HashKey; NE = Enum.C } @> ) test <@ item.HashKey = item'.NestedList[0].NV @>