Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty strings not written to SimpleDb #19

Open
aarong opened this issue Nov 4, 2011 · 1 comment
Open

Empty strings not written to SimpleDb #19

aarong opened this issue Nov 4, 2011 · 1 comment

Comments

@aarong
Copy link

aarong commented Nov 4, 2011

When using putItem or batchPutItem empty strings are not written to SDB. These writes do not seem to be included in the API request, maybe because "" == false somewhere.

To replicate:

var SimpleDb = require('simpledb');

var sdb = new SimpleDb.SimpleDB({
    keyid:      'keyid',
    secret:     'secret'
});

var fPutGet = function (inItemName, inValue) {

    // Write the item to SDB and read it back
    sdb.putItem(
        'testDomain',
        inItemName,
        { 'someAttribute': inValue },
        function (inError, inResult, inMeta) {

            console.log('putItem done (' + inItemName + ':' + inValue + '), error:', inError);

            sdb.getItem(
                'testDomain',
                inItemName,
                function (inError, inResult, inMeta) {

                    console.log('getItem done (' + inItemName + ':' + inValue + '), result:', inResult);

                }
            );

        }
    );

}

sdb.createDomain(
    'testDomain',
    function () {

        console.log('createDomain done');
        fPutGet('item1', 'not empty');
        fPutGet('item2', '');

    }
);
@aarong
Copy link
Author

aarong commented Nov 4, 2011

Also I just noticed that if you force a putItem API request to write an empty string using an override argument like this:

{
            'Attribute.0.Name': 'someAttribute',
            'Attribute.0.Value': '',
            'Attribute.0.Replace': "true"
}

and then read back the attribute using getItem, you get "[object Object]" as the value for the attribute. To replicate:

var SimpleDb = require('simpledb');

var sdb = new SimpleDb.SimpleDB({
    keyid:      'keyid',
    secret:     'secret'
});


var fPutGet = function (inItemName, inValue) {

    // Write the item to SDB and read it back
    sdb.putItem(
        'testDomain',
        inItemName,
        {},
        {
            'Attribute.0.Name': 'someAttribute',
            'Attribute.0.Value': inValue,
            'Attribute.0.Replace': "true"
        },
        function (inError, inResult, inMeta) {

            console.log('putItem done (' + inItemName + ':' + inValue + '), error:', inError);

            sdb.getItem(
                'testDomain',
                inItemName,
                function (inError, inResult, inMeta) {

                    console.log('getItem done (' + inItemName + ':' + inValue + '), result:', inResult);

                }
            );

        }
    );

}

sdb.createDomain(
    'testDomain',
    function () {

        console.log('createDomain done');
        fPutGet('item1', 'not empty');
        fPutGet('item2', '');

    }
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant