Skip to content

using scopes removes foreign keys? #6245

@yocontra

Description

@yocontra

What you are doing?

const scopes = {
  public: {
    attributes: {
        exclude: ['secret']
    }
  }
}

// imagine i made a model named User with two fields:
// - secret
// - name
User.belongsTo(City) // user now has cityId field

User.scope('public').findById(123).then((user) =>
  // user === { id: 123, name: 'Bob' }
)

What do you expect to happen?

The foreign key cityId should exist on the result

What is actually happening?

The foreign key cityId does not exist on the result

When not using scopes, cityId appears in the result as expected.

Dialect: postgres
Sequelize version: 3.23.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugDEPRECATED: replace with the "bug" issue type

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions