sails: columnType 'bigint' not working
Waterline version: 0.13 Node version: 7.10 NPM version: 4.2.0 Operating system: Mac OS El Capitan
Hello guys ! I’m currently facing a strange issue using columnType: ‘bigint’ which is raising a warning (see attachment). Currently using sails-postgresql 1.0.0
Here is my Model.js
module.exports = {
attributes: {
lastActivity: {
type: 'number',
columnType: 'bigint',
defaultsTo: +new Date()
}
}
}
- I tried to clean my database but the warning still appears
- I tried on a fresh new sails project
Any ideas what’s going on ?
Best,
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 18 (6 by maintainers)
@sgress454 I am having a very similar data transformation issue, but I am concerned that our data-science team will have some issues with unix timestamp stored in
bigintcolumns.When I use the
timestampdata type it seems to be getting converted to aDateobject before the validation check when processing all selected records. The value then fails the_.isString || _.isNumbertest (the attribute value is resolves as an[object Date]).That looks like a string, but I think it’s actually some kind of Date -> String conversion that is happening in
util.inspect().Would it be a safe workaround to develop my own createdAt and updatedAt functionality using beforeCreate/beforeUpdate lifecycle callbacks using the
reftype? (I am still not 100% confident that I understand what thereftype is.) For example…Thanks!
@billyshena @edencorbin The issue is that the max “bigint” value is larger than the max JavaScript integer value, so it needs to be stored as a string. See https://github.com/balderdashy/sails/issues/4064. You’ll need to define your attribute like so: