Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can DynamoDb range key be empty?

Tags:

I am looking at using DynamoDb for one of my applications.

I wanted to know if it's possible to set an attribute as range key and then leave it unpopulated for certain records(either empty or null).

like image 208
somesh Avatar asked Jun 01 '16 09:06

somesh


1 Answers

You can't insert an item with Range Key as empty value or without the Range key.

If the Range key is not included. You would get the below error:-

"One of the required keys was not given a value" 

If the Range key is populated with '' (i.e. empty string)

"message": "One or more parameter values were invalid: An AttributeValue may not contain an empty string" 

From AWS Doc:-

When you add an item, the primary key attribute(s) are the only required attributes. Attribute values cannot be null. String and Binary type attributes must have lengths greater than zero. Set type attributes cannot be empty. Requests with empty values will be rejected with a ValidationException exception.

like image 194
notionquest Avatar answered Oct 26 '22 16:10

notionquest