Question

I am trying to create a sequelize model for a table that has an options column, but I get an error when I attempt a query (like find, for example):

/Users/camupod/node_modules/sequelize/lib/sequelize/model.js:17
  var defaults = this.options.hasPrimaryKeys ? {} : { id: null }
                             ^
TypeError: Cannot read property 'hasPrimaryKeys' of null
    at new <anonymous> (/Users/camupod/node_modules/sequelize/lib/sequelize/model.js:17:30)
    at [object Object].build (/Users/camupod/node_modules/sequelize/lib/sequelize/model-definition.js:140:18)
    at /Users/camupod/node_modules/sequelize/lib/sequelize/query.js:47:64
    at Array.map (native)
    at [object Object].onSuccess (/Users/camupod/node_modules/sequelize/lib/sequelize/query.js:47:22)
    at /Users/camupod/node_modules/sequelize/lib/sequelize/query.js:22:38
    at Query.<anonymous> (/Users/camupod/node_modules/mysql/lib/client.js:108:11)
    at Query.emit (events.js:61:17)
    at Query._handlePacket (/Users/camupod/node_modules/mysql/lib/query.js:51:14)
    at Client._handlePacket (/Users/camupod/node_modules/mysql/lib/client.js:312:14)

And my model's definition:

Model.recording = sequelize.define(
    'recordings',
    {
        /* other columns... */
        options: Sequelize.TEXT
    },
    {
        timestamps: false,
        freezeTableName: true
    }
);

Does sequelize really not allow options as a column name, or am I doing something wrong?

Was it helpful?

Solution

Well, that's a pretty stupid "edgecase". Defining an attribute called "options" will overwrite the options of the model :D that sucks :(.

The issue was just fixed and the bugfix is available in v1.1.3. Please let me know if that works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top