Closed sans-ericstewart closed 4 years ago
Hi @sans-ericstewart
Thanks for the detailed issue description.
Basically it is not a bug but somehow an expectable behaviour.
dynamo-easy relies on typescript reflection information design:type
to skip type checks on values at runtime. When defining masterAccountId: string | null
the emitted design type is Object
and not String
--> this results in dynamo-easy trying to treat your string value like an object and therefore it fails. The null value on the other hand is ignored and won't be sent to dynamoDB since this is the default behaviour of dynamo-easy.
Unfortunately dynamo-easy does not yet support null values for properties.
My first idea was to handle your case by simply creating a custom mapper, but all null or undefined values are filtered out before the mapper is called. So this won't work as well.
tl;dr
{S:'val'}
or {NULL:true}
to DynamoDB.masterAccountId?: string
I opened the issue #285 for the feature request.
Describe the Bug When a GSI Partition Key is declared as string or null, put transactions fail when the value for the GSI Partition Key is a string. The put transaction does not fail when it's value is null.
This situation occurs when you want to use a sparse index on the GSI. In this case, we declare the GSI Partition Key to be string or null.
Code to Reproduce the Issue
Expected behavior Both transactions should be assembled and be ready to execute with transaction writer. However, the second put transaction fails with the following error. Curiously, the first transaction is assembled without issue.
Desktop (please complete the following information):
Package: