domasx2 / sequelize-fixtures

Load data from json, yaml or js to sequelize
301 stars 83 forks source link

TypeError: Cannot read property 'warn' of undefined #112

Closed hugodes closed 4 years ago

hugodes commented 5 years ago

Since the latest update I've been getting this error on the .loadFiles() method.

I call

return sf.loadFiles([
        <my fixtures>
      ], models, {
        logger: {
          debug: console.log,
          info: console.log,
          warn: console.log,
          error: console.log,
        },
      }).catch((err) => console.log(err));

And get the error

TypeError: Cannot read property 'warn' of undefined
    at /Users/hugodes/src/core/corejs/node_modules/sequelize-fixtures/lib/loader.js:249:29
    at Array.forEach (<anonymous>)
    at module.exports.Loader.prepFixtureData (/Users/hugodes/src/core/corejs/node_modules/sequelize-fixtures/lib/loader.js:171:23)
    at module.exports.Loader.loadFixture (/Users/hugodes/src/core/corejs/node_modules/sequelize-fixtures/lib/loader.js:52:17)
    at module.exports.<anonymous> (/Users/hugodes/src/core/corejs/node_modules/sequelize-fixtures/lib/loader.js:17:21)
    at tryCatcher (/Users/hugodes/src/core/corejs/node_modules/bluebird/js/release/util.js:16:23)
    at Object.gotValue (/Users/hugodes/src/core/corejs/node_modules/bluebird/js/release/reduce.js:155:18)
    at Object.gotAccum (/Users/hugodes/src/core/corejs/node_modules/bluebird/js/release/reduce.js:144:25)
    at Object.tryCatcher (/Users/hugodes/src/core/corejs/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/hugodes/src/core/corejs/node_modules/bluebird/js/release/promise.js:517:31)
    at Promise._settlePromise (/Users/hugodes/src/core/corejs/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromise0 (/Users/hugodes/src/core/corejs/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise._settlePromises (/Users/hugodes/src/core/corejs/node_modules/bluebird/js/release/promise.js:699:18)
    at _drainQueueStep (/Users/hugodes/src/core/corejs/node_modules/bluebird/js/release/async.js:138:12)
    at _drainQueue (/Users/hugodes/src/core/corejs/node_modules/bluebird/js/release/async.js:131:9)
    at Async._drainQueues (/Users/hugodes/src/core/corejs/node_modules/bluebird/js/release/async.js:147:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/hugodes/src/core/corejs/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)

It seems to be linked to node_modules/sequelize-fixtures/lib/loader.js:249:29 which was changed in this commit : https://github.com/domasx2/sequelize-fixtures/commit/d8f7150ece249a42923ed4af01457bd7c55f85ea

hugodes commented 5 years ago

@matmar10

lukas1994 commented 5 years ago

having the same issue - did you find a work-around?

lukas1994 commented 5 years ago

It's coming from this line: this.logger.warn('attribute "' + key +"' not defined on model '" + Model.name + "'."); My fixtures contained an attribute that I removed from the model earlier, removing them fixed it.

Would still be great to see the log message instead of this error :)

hugodes commented 5 years ago

I made PR that fixes the issue here: #114

gambhirpulkit commented 4 years ago

Can someone please merge the PR fix so that it gets updated?