New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute exclusion crashes when specified in defaultScope #4735

Closed
curiousdannii opened this Issue Oct 27, 2015 · 2 comments

Comments

5 participants
@curiousdannii
Contributor

curiousdannii commented Oct 27, 2015

If I try to exclude an attribute (#4074) by default using defaultScope:

        defaultScope: {
            attributes: { exclude: [ 'documentation' ] },
        },

An error is thrown:

/home/dannii/i7el/node_modules/sequelize/lib/model.js:2592
    var attributes = Object.keys(this.tableAttributes);
                            ^

TypeError: Cannot convert undefined or null to object
    at Function.keys (native)
    at Model.$expandAttributes (/home/dannii/i7el/node_modules/sequelize/lib/model.js:2592:29)
    at conformOptions (/home/dannii/i7el/node_modules/sequelize/lib/model.js:245:10)
    at Model.init (/home/dannii/i7el/node_modules/sequelize/lib/model.js:698:5)
    at Sequelize.define (/home/dannii/i7el/node_modules/sequelize/lib/sequelize.js:582:17)
    at module.exports (/home/dannii/i7el/db/Extension.js:7:19)

@curiousdannii curiousdannii changed the title from Attribute exclusions crashes when specified in defaultScope to Attribute exclusion crashes when specified in defaultScope Oct 27, 2015

@phuvo

This comment has been minimized.

phuvo commented Nov 1, 2015

+1. Workaround by using addScope('defaultScope') after defining the model.

@matomesc

This comment has been minimized.

matomesc commented Dec 15, 2015

Getting this as well on:

node@4.2.2
npm@2.14.7
sequelize@3.14.2

I believe that this.tableAttributes (which is undefined) should be this.attributes, which references the correct attributes object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment