question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'toUpperCase' of undefined

See original GitHub issue

I keep getting this error when I try to define the associations for my models.

turn str.trim().replace(/[-_\s]+(.)?/g, function(match, c){ return c.toUpperCa
                                                                    ^
TypeError: Cannot read property 'toUpperCase' of undefined
    at /home/user/node/project/node_modules/sequelize/lib/utils.js:51:75

The line in question is:

Project.belongsToMany(Owner, { as: 'Projects', foreignKey: 'project_id', through: 'project_owners' });

The problem seems to be the Owner model. However, if I do console.log(Owner.tableName);, I do get the expected output.

What might be the cause of this?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
janmeiercommented, Aug 9, 2015

Hmm… Can you post a reproducible test case?

Do both target and source have primary keys? And are the marked as such with primaryKey: true?

0reactions
shawnindercommented, Nov 3, 2017

I have a case where both tables have a primary key and there are no underscores anywhere, yet I still get this error. I also have a repo which reproduces the issue: https://github.com/WaltzApp/sequelize-troubleshooting

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: Cannot read property 'toUpperCase' ...
am getting this error Uncaught TypeError: Cannot read property 'toUpperCase' of undefined .I have also tried to convert toString() first and ...
Read more >
Cannot read property 'toUpperCase' of Undefined in JS
The "Cannot read property 'toUpperCase' of undefined" error occurs when calling the toUpperCase() method on an undefined value. To solve the error, initialize ......
Read more >
Cannot read property 'toUpperCase' of undefined
This error occurs when a property is read or a function is called on an undefined variable. Undefined means that a variable has...
Read more >
TypeError: Cannot read property 'toUpperCase' of undefined
It seems like you're trying to remove opposite pairs of direction. A possible iterative solution might be: // We make a copy of...
Read more >
Cannot read property 'toUpperCase' of undefined #3307
It appears name[ 0 ] is not defined. Probalble causes i can think of is that name variable is not defined. Try doing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found