Closed thoean closed 7 years ago
+1
+1
+1
+1
+1, and at least be more specific in error message.
+1
@LiuJoyceC could you disclose whether this is something that is actually being worked on or even discussed internally? I only ask because this bug seems to be almost a half-decade old. So is this something that actually could be fixed but hasn't, or is it a fundamental limitation of the DynamoDB internal structure?
Glad to see something is being done, but that's really just trading one problem for a new one.
+1
+1
@brandonmbanks Converting empty values to null
is now an opt-in feature of the document client; you can pass a boolean convertEmptyValues
option to the document client constructor to have it do so. I'll open a PR to improve the documentation of this feature.
+1
+1
+1
+1
+1
+1
+1
this is much needed, please...
@yipcma As noted above, this has been implemented as an opt-in feature. Set the convertEmptyValues
constructor option to true
when creating a document client.
@jeskew I think what people want is the ability to store and retrieve an empty string. All this provides is a way to convert empty strings to null
which really isn't the same thing.
People want to be able to store JSON documents in DynamoDB but right now we only have two options: 1) store the full JSON as a string in a single column, or 2) use convertEmptyValues
and accept that you will not be able to use 100% of the JSON spec without data loss.
Unfortunately, that isn't something that can be handled client-side without knowledge of the expected data schema.
If the SDK included a higher-level abstraction that knew which types certain fields were expected to be (like the AWS SDK for Java's DynamoDB Data Mapper or the Ruby Aws::Record
), then the client could convert a null
value to an empty string or empty buffer as appropriate. That's a reasonable feature request, but it's not something that could be built into the document client without introducing breaking changes.
+1 from me +1 from Leanne
+1
+1
+1
+1
+1000
ive never seen a issue desired like this one. Any roadmap to implement the possibility to store an empty string in dynamodb? should everyone move to another database? 🙏🏼
@superandrew We've implemented opt-in, client-side support for this feature via the convertEmptyValues flag as discussed above.
in my opinion, this is more of a client side patch for something that needs to be done on the dynamodb side. And, more importantly, and as someone else said before me, null is no replacement for an empty string. So if more and more people keeps asking for a more complete fix, I wouldn't call this issue "closed". But, of course, still my opinion.
Just wanted to remind everyone to please keep the discussion constructive.
@superandrew I understand what you mean, but the SDK is a client-side library, and the DynamoDB team does not monitor the issue queue of any AWS SDK. For a server-side fix, I recommend that you reach out directly to the DynamoDB team via their AWS Developer Forum or via a support ticket.
@jeskew you can accelerate this type of request to AWS Team where plenty of people is facing issue with kind of problems! Though its almost 2 years, Developer finds a way on their(client) side as well!! LET IT GO!
@jeskew this bug is now more than half a decade old. No one seems to be getting satisfaction over there so they are voicing their concerns here. Perhaps AWS could open-source DynamoDB and put the code up on GitHub so we could create an issue there and/or make a PR which allows empty strings to be stored.
+1
+1
+1
Slight change to the code suggested by @bo01ean so that it tokenizes and detokenizes the empty string. It works for me but it's annoying that I need to do this to preserve the original JSON when using dynamodb.
const token = '~&*^AWSSTILLHASNOTFIXEDTHIS!!!~&*^';
const tokenizeEmptyStringElements = function (obj) {
for (var prop in obj) {
if (typeof obj[prop] === 'object') {// dive deeper in
tokenizeEmptyStringElements(obj[prop]);
} else if(obj[prop] === '') {
// tokenize elements that are empty strings
obj[prop] = token
}
}
return obj;
}
const detokenizeEmptyStringElements = function (obj) {
for (var prop in obj) {
if (typeof obj[prop] === 'object') {// dive deeper in
detokenizeEmptyStringElements(obj[prop]);
} else if(obj[prop] === token) {
// tokenize elements that are empty strings
obj[prop] = ''
}
}
return obj;
}
+1
+1
AWS Error Type: client, AWS Error Message: One or more parameter values were invalid: An AttributeValue may not contain an empty string
Validate empty string with " " SPACE
+1
+1
+1
+1
+1
+1
+8
+1
When the object contains a property with an empty string, it results in an exception instead of for example silently removing this property or replacing with a user-provided constant.
To be specific, the following example request:
Results in the following error on DynamoDB:
Which is returned from the DocumentClient as: