From 3905973d5e7316cfee7d0b8182e308cf9b1f48f3 Mon Sep 17 00:00:00 2001 From: Thomas Hambach Date: Mon, 7 Sep 2015 10:47:06 +0800 Subject: [PATCH] Added flag to allow unicode strings https://github.com/sequelize/sequelize/issues/3752 --- lib/dialects/mssql/query-generator.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/dialects/mssql/query-generator.js b/lib/dialects/mssql/query-generator.js index 94971256a8f7..5d9e10e4a330 100644 --- a/lib/dialects/mssql/query-generator.js +++ b/lib/dialects/mssql/query-generator.js @@ -4,7 +4,8 @@ var Utils = require('../../utils') , DataTypes = require('../../data-types') , Model = require('../../model') - , AbstractQueryGenerator = require('../abstract/query-generator'); + , AbstractQueryGenerator = require('../abstract/query-generator') + , SqlString = require('../../sql-string'); /* istanbul ignore next */ var throwMethodUndefined = function(methodName) { @@ -603,7 +604,27 @@ var QueryGenerator = { booleanValue: function(value) { return !!value ? 1 : 0; + }, + + escape: function(value, field) { + if (value && value._isSequelizeMethod) { + return this.handleSequelizeMethod(value); + } else { + if (field && field.type && value) { + if (field.type.validate) { + field.type.validate(value); + } + } + + var escaped = SqlString.escape(value, false, this.options.timezone, this.dialect, field); + if (typeof value === "string" && (!field || field.type instanceof DataTypes.STRING)) { + return 'N' + escaped; + } + return escaped; + + } } + }; // private methods