UNPKG

@themost/mssql

Version:
41 lines (35 loc) 1.24 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var mssql = require('@themost/mssql'); class MSSqlAdapter2 extends mssql.MSSqlAdapter { /** * @param {*} options */ constructor(options) { super(options); } formatType(field) { const nullable = Object.prototype.hasOwnProperty.call(field, 'nullable') ? field.nullable ? 'NULL' : 'NOT NULL' : 'NULL'; // override Text and URL if (field.type === 'Text' || field.type === 'URL') { return field.size > 0 ? `nvarchar(${field.size}) ${nullable}` : `nvarchar(512) ${nullable}`; } // override Note if (field.type === 'Note') { return field.size > 0 ? `nvarchar(${field.size}) ${nullable}` : `nvarchar(max) ${nullable}`; } // otherwise use default return super.formatType(field); } } /** * Creates an instance of MSSqlAdapter object that represents a MSSQL database connection. * @param {*} options An object that represents the properties of the underlying database connection. * @returns {MSSqlAdapter2} */ function createInstance(options) { return new MSSqlAdapter2(options); } exports.MSSqlAdapter2 = MSSqlAdapter2; exports.createInstance = createInstance; //# sourceMappingURL=index.js.map