1

I am using Sails alongside its Waterline ORM for PostgreSQL. I am having an issue with the defaultsTo parameter in model attribute definition.

Here is a part of my Model definition:

module.exports = {
  tableName: 'table',

  attributes: {
    [...]
    reach: {
      type: 'number',
      defaultsTo: 0,
    }
    [...]
  }
}

When using Model.create(), I get this console warning:

Warning: After transforming columnNames back to attribute names for model `model`,
 a record in the result has a value with an unexpected data type for property `reach`.
The corresponding attribute declares `type: 'number'` but instead
of that, the actual value is:
` ` `
'0'
` ` ` 

I have a bunch of number type attributes so this leads to a lot of warnings in my console.

At this point, I believe this is a waterline issue but do you have a workaround to avoid this warning?


Edit

My warning is only appearing for Postgres "BIGINT" column I am starting to undersand that JS cannot handle postgres BIGINT as number so it must be converted to string.

benomite
  • 848
  • 7
  • 23

1 Answers1

1

I found a way to avoid warning : set attribute a different way:

attributes: {
  [...]
  reach: {
    type: 'ref',
    columnType: 'bigint',
    isNumber: true,
    defaultsTo: 0
  },
  [...]
}
benomite
  • 848
  • 7
  • 23