Allow empty Dynamodb Sets to be instantiated
Is your feature request related to a problem? Please describe. I want to create a script to initialise documents in a clean/empty DynamoDB environment. One of these documents should contain a StringSet however with no values initially.
I wish to run something like:
const DynamoDBSet = require('aws-sdk/lib/dynamodb/set');
const mySet = new DynamoDBSet([]);
The above however returns an exception reading: InvalidSetType: Sets can contain string, number, or binary values
(Comes from: https://github.com/aws/aws-sdk-js/blob/b6d3eba/lib/dynamodb/set.js#L36-L41)
I would like to be able to create this object without an exception being thrown, however being able to specify the set type on instantiation.
Describe the solution you'd like
Support for an interface similar to the following will be ideal:
const DynamoDBSet = require('aws-sdk/lib/dynamodb/set');
const mySet = new DynamoDBSet([]);
mySet.setType('String');
console.log(mySet);
// Set { wrapperName: 'Set', values: [ ], type: 'String' }
Describe alternatives you've considered My workaround is as follows:
const DynamoDBSet = require('aws-sdk/lib/dynamodb/set');
function createEmptyStringset() {
const set = new DynamoDBSet(['temp_value']);
set.values = [];
return set;
}
Additional context No.
I realise now that saving an empty stringset is also not possible, so for now I am setting in a wanted value and persisting that instead.
DynamoDB service doesn't allow storing empty sets (irrespective of type). From documentation:
An attribute value cannot be an empty string or empty set (string set, number set, or binary set). However, empty lists and maps are allowed. For more information, see Attributes.
And it indeed works this way:

I don't think there's anything the AWS JS SDK can do about it.
I agree. Thanks for looking.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.