gadelkareem / sails-dynamodb

Amazon DynamoDB adapter for Waterline / Sails.js
http://sailsjs.org
46 stars 22 forks source link

BOOL schema type and upgrade vogels #46

Open trung-huynh opened 6 years ago

trung-huynh commented 6 years ago

Hi there,

There is an error in current vogels version (~0.12.0) with BOOL schema type which is using 'N' dynamoDB attribute value instead of 'BOOL' attribute value, I guess probably because at the point of developing that vogels version, dynamoDB wasn't support BOOL type yet, the code I investigated in vogels 0.12.0:

Schema.prototype.Boolean = function (attrName, options) {
  var attributeType = 'N';
  return internals.baseSetup(this, attrName, Joi.boolean(), attributeType, options);
};

The latest vogels version (2.2.0) as well as dynamoDB has supported BOOL and it leads to data inconsistency if sails-dynamodb still uses the old version of vogel, here is the code snippet from latest vogels:

internals.wireType = function (key) {
  switch (key) {
    case 'string':
      return 'S';
    case 'date':
      return 'DATE';
    case 'number':
      return 'N';
    case 'boolean':
      return 'BOOL';
    case 'binary':
      return 'B';
    case 'array':
      return 'L';
    default:
      return null;
  }
};

Do you have any plan to update to the latest version?

Many thanks, Trung.

ferrants commented 6 years ago

I have no plans to update this, but I'm happy to look at a PR.

elipeters commented 6 years ago

throw new Error("Wrong filter given :" + filter); filter is out of scope and throws undefined