TypeError: Cannot read property '2' of null
See original GitHub issueWhat you are doing?
Creating a record with the same value in a column that is Unique:true. I’m using FeathersJS with uses Sequelize. I successfully inserted new record via restful api using Postman. However if I send the same request again( create a user with the same email which the column is unique) it crashes the server with error “TypeError: Cannot read property ‘2’ of null”.
Below is the model I am using
// code here
const Sequelize = require('sequelize');
module.exports = function(sequelize) {
const user = sequelize.define('users', {
email: {
type: Sequelize.STRING,
allowNull: false,
unique: true
},
password: {
type: Sequelize.STRING,
allowNull: false
}
}, {
freezeTableName: true
});
What do you expect to happen?
I expected to get a response back with an error stating its a duplicate or at least a clean error.
What is actually happening?
Crashed server since error wasn’t caught.
Output, either JSON or SQL
Dialect: mysql Database version: 5.7.13 Sequelize version: 3.24.4
Issue Analytics
- State:
- Created 7 years ago
- Comments:15 (8 by maintainers)
Top Results From Across the Web
Uncaught TypeError: Cannot read property '2' of null
Uncaught TypeError: Cannot read property '2' of null. The error appears only when reloading the page. So I assume the cookie is there...
Read more >Uncaught TypeError: Cannot read property of null - iDiallo
This error occurs when you read a property or call a method on a null object . That's because the DOM API returns...
Read more >TypeError: Cannot read property 'value' of Null in JS
To solve the "Cannot read property 'value' of null" error, make sure that the JS script tag is placed at the bottom of...
Read more >Uncaught (in promise) TypeError: Cannot read property '2' of null
Any help would be appreciated. The error is “Uncaught (in promise) TypeError: Cannot read property '2' of null” in www/framework7/js/framework7.
Read more >[Charts] - Reactive : Cannot read property '2' of null.
[Charts] - Reactive : Cannot read property '2' of null. Question. Charts. Hi Outsys Devs! I'm asking for help on how to solve...
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
The issue is here:
https://github.com/sequelize/sequelize/blob/f8a98a145443c890be9cab4c941abda28845e4c0/lib/dialects/mysql/query.js#L199-L212
I put a log statement to see the
err
and it looks like this.There is no
err.message
somatch
isnull
, and there are 2 statements that don’t guard against it.and
I am using
MySQL 5.7.21
this is till happening when I try to update a record with a column (that is set to
unique:true
) with a non unique value,