不要怂,就是干,撸起袖子干!

Commit b495d5ed by McGrady Chen Committed by GitHub

fix(mssql) insert record failure because of BOOLEAN column type (#12090)

1 parent 5d51e696
...@@ -36,6 +36,8 @@ class Query extends AbstractQuery { ...@@ -36,6 +36,8 @@ class Query extends AbstractQuery {
//Default to a reasonable numeric precision/scale pending more sophisticated logic //Default to a reasonable numeric precision/scale pending more sophisticated logic
paramType.typeOptions = { precision: 30, scale: getScale(value) }; paramType.typeOptions = { precision: 30, scale: getScale(value) };
} }
} else if (typeof value === 'boolean') {
paramType.type = TYPES.Bit;
} }
if (Buffer.isBuffer(value)) { if (Buffer.isBuffer(value)) {
paramType.type = TYPES.VarBinary; paramType.type = TYPES.VarBinary;
......
...@@ -132,4 +132,28 @@ if (dialect.match(/^mssql/)) { ...@@ -132,4 +132,28 @@ if (dialect.match(/^mssql/)) {
expect(Number(record.business_id)).to.equals(bigIntValue); expect(Number(record.business_id)).to.equals(bigIntValue);
}); });
}); });
it('saves boolean is true, #12090', function() {
const BooleanTable = this.sequelize.define('BooleanTable', {
status: {
type: Sequelize.BOOLEAN,
allowNull: false
}
}, {
freezeTableName: true
});
const value = true;
return BooleanTable.sync({ force: true })
.then(() => {
return BooleanTable.create({
status: value
});
})
.then(() => BooleanTable.findOne())
.then(record => {
expect(record.status).to.equals(value);
});
});
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!