Skip to content

Cannot read property 'key' of undefined #7932

Closed

Description

@raultomescu

What you are doing?

acceptedCandidates: {
      type: Sequelize.ARRAY,
      field: 'accepted_candidates',
      allowNull: false,
    },

What do you expect to happen?

See nice error telling me that I did not put a type for the elements of the array.

What is actually happening?

Unhandled error cannot read property key of undefined

 TypeError: Cannot read property 'key' of undefined

      at Sequelize.Object.<anonymous>.Sequelize.normalizeDataType (node_modules/sequelize/lib/sequelize.js:1366:64)
      at Sequelize.Object.<anonymous>.Sequelize.normalizeAttribute (node_modules/sequelize/lib/sequelize.js:1378:25)
      at Model.<anonymous> (node_modules/sequelize/lib/model.js:84:32)

__Dialect: postgres
__Database version: --
__Sequelize version: 3.30.2

Activity

  1. austinyearlykim commented on Aug 24, 2017

    @austinyearlykim

    it is erroring at if (type instanceof DataTypes.ARRAY && dialectTypes[type.type.key]) {

    hmmm.

  2. austinyearlykim commented on Aug 24, 2017

    @austinyearlykim

    Got it. @RaulTsc

    You need to add a type for your array. What type are the values held by it?

    Here is something of the sort below:
    acceptedCandidates: { type: Sequelize.ARRAY(Sequelize.TEXT), field: 'accepted_candidates', allowNull: false, },

    yay

  3. stale commented on Sep 23, 2017

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂

  4. raultomescu commented on Sep 30, 2017

    @raultomescu
    Author

    Makes sense @austindebruyn . Still, it's a weird error message. A nice message would be useful.

  5. austindebruyn commented on Sep 30, 2017

    @austindebruyn
    Contributor

    You most likely meant to tag @austinyearlykim 😃

  6. alexanmtz commented on Apr 4, 2018

    @alexanmtz

    In my case I was using array that is supported just by postgres and in my local env is not supported, so after remove the array datatype it works

  7. added
    good first issue
    and removed on Apr 6, 2018
  8. sushantdhiman commented on Sep 8, 2018

    @sushantdhiman
    Contributor

    Fixed by #9649

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions