jon*_*iba 1 sql-server node.js sequelize.js
使用node.js和sequelize vis-a-vis MSSQL,如何定义NVARCHAR(MAX)字段?
小智 7
如果在Sequelize中将数据类型设置为TEXT,则会自动将该字段转换NVARCHAR(MAX为SQL Server数据库.
我在文档中找不到这个
但是在第79行到第90行的Sequelize github存储库中提到了它.
在此处粘贴代码段:
TEXT.prototype.toSql = function toSql() {
// TEXT is deprecated in mssql and it would normally be saved as a non-unicode string.
// Using unicode is just future proof
if (this._length) {
if (this._length.toLowerCase() === 'tiny') { // tiny = 2^8
warn('MSSQL does not support TEXT with the `length` = `tiny` option. `NVARCHAR(256)` will be used instead.');
return 'NVARCHAR(256)';
}
warn('MSSQL does not support TEXT with the `length` option. `NVARCHAR(MAX)` will be used instead.');
}
return 'NVARCHAR(MAX)';
};
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,SQL Server不支持TEXT字段,因此它会将其转换为 NVARCHAR(MAX)
| 归档时间: |
|
| 查看次数: |
2177 次 |
| 最近记录: |