TypeError: Cannot read property 'toUpperCase' of undefined
See original GitHub issueI 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:
- Created 8 years ago
- Comments:6 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
?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