Skip to content

Commit

Permalink
Fixes a bug with the minified version of the browser SDK where sendin…
Browse files Browse the repository at this point in the history
…g Sets of data with the DynamoDB DocumentClient would cause an error to be returned from the service. (#1990)
  • Loading branch information
chrisradek committed Mar 29, 2018
1 parent 5349bc8 commit b663ae8
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-DocumentClient-bd9eaf09.json
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "DocumentClient",
"description": "Fixes a bug with the minified version of the browser SDK where sending Sets of data with the DynamoDB DocumentClient would cause an error to be returned from the service."
}
1 change: 1 addition & 0 deletions lib/dynamodb/numberValue.js
Expand Up @@ -10,6 +10,7 @@ var util = require('../core').util;
*/
var DynamoDBNumberValue = util.inherit({
constructor: function NumberValue(value) {
this.wrapperName = 'NumberValue';
this.value = value.toString();
},

Expand Down
1 change: 1 addition & 0 deletions lib/dynamodb/set.js
Expand Up @@ -18,6 +18,7 @@ var DynamoDBSet = util.inherit({

constructor: function Set(list, options) {
options = options || {};
this.wrapperName = 'Set';
this.initialize(list, options.validate);
},

Expand Down
2 changes: 1 addition & 1 deletion lib/dynamodb/types.js
Expand Up @@ -6,7 +6,7 @@ function typeOf(data) {
} else if (data !== undefined && isBinary(data)) {
return 'Binary';
} else if (data !== undefined && data.constructor) {
return util.typeName(data.constructor);
return data.wrapperName || util.typeName(data.constructor);
} else if (data !== undefined && typeof data === 'object') {
// this object is the result of Object.create(null), hence the absence of a
// defined constructor
Expand Down
2 changes: 1 addition & 1 deletion tasks/browser.rake
Expand Up @@ -50,7 +50,7 @@ namespace :browser do
end

task :build_all => [:setup_dist_tools, :dist_path] do
sh({"MINIFY" => ""}, "#{$BUILDER} all > dist/aws-sdk-all.js")
sh({"MINIFY" => "1"}, "#{$BUILDER} all > dist/aws-sdk-all.js")
end

desc 'Caches assets to the dist-tools build server'
Expand Down
8 changes: 4 additions & 4 deletions test/dynamodb/converter.spec.js
Expand Up @@ -429,7 +429,7 @@ describe('AWS.DynamoDB.Converter', function() {
'should convert StringSetAttributeValues into sets with strings',
function() {
var converted = output({SS: ['a', 'b', 'c']});
expect(converted).to.have.keys('values', 'type');
expect(converted).to.have.keys('values', 'type', 'wrapperName');
expect(converted.type).to.equal('String');
expect(converted.values).to.deep.equal(['a', 'b', 'c']);
}
Expand All @@ -441,7 +441,7 @@ describe('AWS.DynamoDB.Converter', function() {
'should convert NumberSetAttributeValues into sets with numbers',
function() {
var converted = output({NS: ['1', '2', '3']});
expect(converted).to.have.keys('values', 'type');
expect(converted).to.have.keys('values', 'type', 'wrapperName');
expect(converted.type).to.equal('Number');
expect(converted.values).to.deep.equal([1, 2, 3]);
}
Expand All @@ -456,7 +456,7 @@ describe('AWS.DynamoDB.Converter', function() {
{wrapNumbers: true}
);

expect(converted).to.have.keys('values', 'type');
expect(converted).to.have.keys('values', 'type', 'wrapperName');
expect(converted.type).to.equal('Number');
for (var i = 0; i < converted.values.length; i++) {
expect(converted.values[i].toString()).to.equal(unsafeInteger);
Expand All @@ -471,7 +471,7 @@ describe('AWS.DynamoDB.Converter', function() {
function() {
var b64Strings = ['dead', 'beef', 'face'];
var converted = output({BS: b64Strings.map(AWS.util.base64.decode)});
expect(converted).to.have.keys('values', 'type');
expect(converted).to.have.keys('values', 'type', 'wrapperName');
expect(converted.type).to.equal('Binary');
expect(converted.values.map(AWS.util.base64.encode))
.to.deep.equal(b64Strings);
Expand Down

0 comments on commit b663ae8

Please sign in to comment.