awspilot / dynamodb-oop

Speak fluent DynamoDB, write code with fashion, I Promise() 😃
https://awspilot.dev
MIT License
119 stars 28 forks source link

Boolean "false", becomes "undefined" #34

Closed renehauck closed 7 years ago

renehauck commented 7 years ago

If I use the boolean property "false", the property is presented as "undefined" in the database. What I have done wrong, or is this a bug?

Thanks :-)

adrianpraja commented 7 years ago

Thanks for reporting! Can you provide an example on how to reproduce it ?

I will also do some tests in the meantime, I have not seen this issue before.

adrianpraja commented 7 years ago

I'm unable to find any scenario how this can happen

Can you provide more details?

Thanks

renehauck commented 7 years ago

Sure,

I try this:

var article = {..,isOffer:false,...}

DynamoDB.table('articles').insert(article, function(err,data) {
        console.log( err, data )
    })

Next, I test the result:

 this.dbManager.$DynamoDBOOPClient
            .table(this.tableName)
            .where('_id').eq(id)
            .get((err, result) => {
                ....
                expect(result.isOffer).to.not.be.true;
               ....
            });

and get this error:

Uncaught AssertionError: expected undefined to be false

When i try this:

var article = {..,isOffer:true,...}

DynamoDB.table('articles').insert(article, function(err,data) {
        console.log( err, data )
    })

with

 this.dbManager.$DynamoDBOOPClient
            .table(this.tableName)
            .where('_id').eq(id)
            .get((err, result) => {
                ....
                expect(result.isOffer).to.be.true;
               ....
            });

I get no errors.

I hope it helps

adrianpraja commented 7 years ago

can you add:

DynamoDB
    .table(...)
    .on('beforeRequest', function(op, payload) {
        console.log(op, JSON.stringify(payload,null,"\t"))
    })

for both insert() and get()

renehauck commented 7 years ago

I just made another update before I wrote the functions. And now the boolean type works perfectly. I'm very sorry about this, that was my mistake :-(

adrianpraja commented 7 years ago

No problem, good thing it works now 👍