balderdashy / balderdashy/sails

Warnings triggered by columnType: '_numbertimestamp'

Open
#6,544 4 comments 0 reactions 0 assignees View on GitHub
helpful info or workaround needs better error message needs documentation
Dominant language
JavaScript
Stars
22.8k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

**Node version**: 8.11.3
**Sails version** _(sails)_: 1.0.2
**ORM hook version** _(sails-hook-orm)_: sails-hook-orm@2.1.0
**Sockets hook version** _(sails-hook-sockets)_: 1.5.3
**Organics hook version** _(sails-hook-organics)_: 0.13.2
**Grunt hook version** _(sails-hook-grunt)_: 3.1.0
**Uploads hook version** _(sails-hook-uploads)_: None
**DB adapter & version** _(e.g. sails-mysql@5.55.5)_: sails-postgresql@1.0.1
**Skipper adapter & version** _(e.g. skipper-s3@5.55.5)_: skipper-disk@0.5.11


I've tried adding a timestamp to my `Ammendment` model that would store values from Date.now() as bigInts (as is done with `createdAt` and `updatedAt`).

```
module.exports = {
attributes: {
stopwatch: { type: 'number', required: true },
timeOfDay: {
type: 'number',
autoMigrations: { columnType: '_numbertimestamp' },
required: true
},

...
}
};
```

Sails lifts without any issues, but when I run `Ammendment.find()` or AnotherModel.findOne({id:1}).populate('ammendment')` I get a list of warnings like this:

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

> You are seeing this warning because there are records in your database that don't
> match up with your models. This is often the result of a model definition being
> changed without also migrating leftover data. But it could also be because records
> were added or modified in your database from somewhere outside of Sails/Waterline
> (e.g. phpmyadmin, or another app). In either case, to make this warning go away,
> you have a few options. First of all, you could change your model definition so
> that it matches the existing records in your database. Or you could update/destroy
> the old records in your database; either by hand, or using a migration script.
>
> (For example, to wipe all data, you might just use `migrate: drop`.)
>
> More rarely, this warning could mean there is a bug in the adapter itself. If you
> believe that is the case, then please contact the maintainer of this adapter by opening
> an issue, or visit http://sailsjs.com/support for help.
```

Am I defining the model correctly? Or is this a bug in the db adapter?

Contributor guide

Open the contributing guide

Research direction

Start with the Ammendment model definition, especially the timeOfDay attribute and its autoMigrations columnType, then reproduce the warning with Ammendment.find() or the populate query shown. Inspect how sails-postgresql returns the _numbertimestamp value and compare it with the declared number type. Done means the behavior is explained and the warning is resolved or the supported model definition is documented with a regression test if applicable.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, postgresql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.