Skip to content

Commit cf46c28

Browse files
committed
wip: fix some incompatibilities
1 parent 4294590 commit cf46c28

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/FSharp.AWS.DynamoDB/Expression/ExprCommon.fs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,12 @@ type QuotedAttribute =
249249

250250
/// Wrapper API for writing attribute names and values for Dynamo query expressions
251251
type AttributeWriter(names: Dictionary<string, string>, values: Dictionary<string, AttributeValue>) =
252+
let names = if names = null then Dictionary() else names
253+
let values = if values = null then Dictionary() else values
252254
static let cmp = new AttributeValueComparer()
253255
let vcontents = new Dictionary<AttributeValue, string>(cmp)
254256

255-
new() = new AttributeWriter(new Dictionary<_, _>(), new Dictionary<_, _>())
257+
new() = AttributeWriter(Dictionary(), Dictionary())
256258

257259
member __.Names = names
258260
member __.Values = values

src/FSharp.AWS.DynamoDB/RecordKeySchema.fs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ type TableKeySchemata with
391391
member schema.ApplyToCreateTableRequest(ctr: CreateTableRequest) =
392392
let inline mkKSE n t = KeySchemaElement(n, t)
393393

394-
let keyAttrs = new Dictionary<string, KeyAttributeSchema>()
394+
let keyAttrs = Dictionary<string, KeyAttributeSchema>()
395395
for tks in schema.Schemata do
396396
keyAttrs.[tks.HashKey.AttributeName] <- tks.HashKey
397397
tks.RangeKey |> Option.iter (fun rk -> keyAttrs.[rk.AttributeName] <- rk)
@@ -402,16 +402,14 @@ type TableKeySchemata with
402402
tks.RangeKey |> Option.iter (fun rk -> ctr.KeySchema.Add <| mkKSE rk.AttributeName KeyType.RANGE)
403403

404404
| GlobalSecondaryIndex name ->
405-
let gsi = new GlobalSecondaryIndex()
406-
gsi.IndexName <- name
405+
let gsi = new GlobalSecondaryIndex(IndexName = name, KeySchema = ResizeArray())
407406
gsi.KeySchema.Add <| mkKSE tks.HashKey.AttributeName KeyType.HASH
408407
tks.RangeKey |> Option.iter (fun rk -> gsi.KeySchema.Add <| mkKSE rk.AttributeName KeyType.RANGE)
409408
gsi.Projection <- Projection(ProjectionType = ProjectionType.ALL)
410409
ctr.GlobalSecondaryIndexes.Add gsi
411410

412411
| LocalSecondaryIndex name ->
413-
let lsi = new LocalSecondaryIndex()
414-
lsi.IndexName <- name
412+
let lsi = new LocalSecondaryIndex(IndexName = name, KeySchema = ResizeArray())
415413
lsi.KeySchema.Add <| mkKSE tks.HashKey.AttributeName KeyType.HASH
416414
tks.RangeKey |> Option.iter (fun rk -> lsi.KeySchema.Add <| mkKSE rk.AttributeName KeyType.RANGE)
417415
lsi.Projection <- Projection(ProjectionType = ProjectionType.ALL)

src/FSharp.AWS.DynamoDB/TableContext.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ module internal Streaming =
7979
module internal CreateTableRequest =
8080

8181
let create (tableName, template: RecordTemplate<'TRecord>) throughput streaming customize =
82-
let req = CreateTableRequest(TableName = tableName)
82+
let req = CreateTableRequest(tableName, ResizeArray(), GlobalSecondaryIndexes = ResizeArray(), LocalSecondaryIndexes = ResizeArray(), AttributeDefinitions = ResizeArray()) // init KeySchema to work with efault SDK v4 options
8383
template.Info.Schemata.ApplyToCreateTableRequest req // NOTE needs to precede the throughput application as that walks the GSIs list
8484
throughput |> Option.iter (Throughput.applyToCreateRequest req) // NOTE needs to succeed Schemata.ApplyToCreateTableRequest
8585
streaming |> Option.iter (Streaming.applyToCreateRequest req)
@@ -563,7 +563,7 @@ type TableContext<'TRecord>
563563
if items.Length > 25 then
564564
invalidArg "items" "item length must be less than or equal to 25."
565565
let writeRequests = items |> Seq.map mkWriteRequest |> rlist
566-
let pbr = BatchWriteItemRequest(ReturnConsumedCapacity = returnConsumedCapacity)
566+
let pbr = BatchWriteItemRequest(ReturnConsumedCapacity = returnConsumedCapacity, RequestItems = Dictionary())
567567
pbr.RequestItems[tableName] <- writeRequests
568568
let! ct = Async.CancellationToken
569569
let! response = client.BatchWriteItemAsync(pbr, ct) |> Async.AwaitTaskCorrect

src/FSharp.AWS.DynamoDB/Utils/DynamoUtils.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type AttributeValueComparer() =
3030
if av.NULL.HasValue then
3131
av'.NULL = av.NULL
3232
elif av.BOOL.HasValue then
33-
av.BOOL = av'.BOOL
33+
av'.BOOL = av.BOOL
3434
elif notNull av.S then
3535
notNull av'.S && av.S = av'.S
3636
elif notNull av.N then

0 commit comments

Comments
 (0)