You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug when try to insert integer value in string field. #4255
My Model.js contains a field with type type: DataTypes.STRING(5).
Under Node 0.12 I can insert a integer value to this field without any issue. But under Node 0.10 it gives me error like this -
error: SequelizeValidationError: 2 is not a valid string at STRING.validate (/var/www/test/test/node_modules/sequelize/lib/data-types.js:92:11) at Object.QueryGenerator.escape (/var/www/test/test/node_modules/sequelize/lib/dialects/mysql/query-generator.js:363:22) at Object.QueryGenerator.whereItemQuery (/var/www/test/test/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2130:20) at /var/www/test/test/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1804:25 at /var/www/test/test/node_modules/lodash/index.js:3073:15 at baseForOwn (/var/www/test/test/node_modules/lodash/index.js:2046:14) at Function.forOwn (/var/www/test/test/node_modules/lodash/index.js:3378:16) at Object.QueryGenerator.whereItemsQuery (/var/www/test/test/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1803:9) at Object.QueryGenerator.getWhereConditions (/var/www/test/test/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2180:19) at Object.QueryGenerator.selectQuery (/var/www/test/test/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1393:28) at QueryInterface.select (/var/www/test/test/node_modules/sequelize/lib/query-interface.js:674:25)
@sushantdhiman Because noone thought of implemening that, and noone commented on the PR that it would be a good idea :)
A PR with that feature would be welcomed.
I'm going to loosen up some of the validations as well (e.g. a '2' should be a valid string), when I get around to it - but I'm tied up with finishing my thesis right now
Activity
sushantdhiman commentedon Aug 5, 2015
Additional details
Database :
mysqlsequelize: ^3.3.2sequelize-cli: ^1.3.0mysql: ~2.5.4I have to convert the data to string then it will work with both Node
.12and.10, It appears to be an issue with validator.I am using the
bulkCreateto create the records.promentol commentedon Aug 12, 2015
The same problem with us, need implicitly convert to string
promentol commentedon Aug 12, 2015
But I see if we have integer field and we assign string value, it converts.
sushantdhiman commentedon Aug 12, 2015
I am currently using this patch @promentol
After model setup
//Fix datatype level validation errors introduced in #3472Sequelize.STRING.prototype.validate = function() { return true; };Sequelize.INTEGER.prototype.validate = function() { return true; };Sequelize.DECIMAL.prototype.validate = function() { return true; };Sequelize.TEXT.prototype.validate = function() { return true; };Sequelize.BOOLEAN.prototype.validate = function() { return true; };I don't know why there is no option to turn this off using some configuration. This update it breaking all Insert / Update queries.
janmeier commentedon Aug 12, 2015
@sushantdhiman Because noone thought of implemening that, and noone commented on the PR that it would be a good idea :)
A PR with that feature would be welcomed.
I'm going to loosen up some of the validations as well (e.g. a
'2'should be a valid string), when I get around to it - but I'm tied up with finishing my thesis right nowjanmeier commentedon Aug 13, 2015
Merged into #4314