type TableItem =
{ [<HashKey>]
[<GlobalSecondaryRangeKey(indexName = "Inverted")>]
PrimaryKey: string
[<RangeKey>]
[<GlobalSecondaryHashKey(indexName = "Inverted")>]
SortKey: string
Model: Model }
A keyCondition like this one fails, since both the IsHashKey and IsRangeKey methods evaluate to true:
let tableCtx: TableContext<TableItem> = ...
tableCtx.queryAsync(<@fun tableItem -> tableItem.PrimaryKey = "..." && tableItem.SortKey.StartsWith "..." @>)
// System.ArgumentException: key conditions must satisfy the following constraints:
// * Must only reference HashKey & RangeKey attributes.
// * Must reference HashKey attribute exactly once.
// * Must reference RangeKey attribute at most once.
// * HashKey comparison must be equality comparison only.
// * Must not contain OR and NOT clauses.
// * Must not contain nested operands.
Related to https://github.com/fsprojects/FSharp.AWS.DynamoDB/issues/36
Given a record as described in the issue
A
keyCondition
like this one fails, since both theIsHashKey
andIsRangeKey
methods evaluate to true:If we attempt the range key happy path first the issue goes away and the key condition gets correctly evaluated. I wanted to add a test case in https://github.com/fsprojects/FSharp.AWS.DynamoDB/blob/master/tests/FSharp.AWS.DynamoDB.Tests/ConditionalExpressionTests.fs either by adding a new record type or adding an inverted index to
CondExprRecord
but I wasn't able to get the tests running properly locally, runningdotnet test
runs some of the tests and then just hangs for some reason.