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

Commit 235b3968 by User4martin

make Query.formatBindParameters static

1 parent 5eb25bf0
......@@ -394,7 +394,7 @@ var groupJoinData = function(rows, includeOptions, options) {
* skipUnescape: bool, skip unescaping $$
* skipValueReplace: bool, do not replace (but do unescape $$). Check correct syntax and if all values are available
*/
AbstractQuery.prototype.formatBindParameters = function(sql, values, dialect, replacementFunc, options) {
AbstractQuery.formatBindParameters = function(sql, values, dialect, replacementFunc, options) {
if (!values) {
return [sql, []];
}
......
......@@ -24,6 +24,7 @@ Query.prototype.getInsertIdField = function() {
return 'id';
};
Query.formatBindParameters = AbstractQuery.formatBindParameters;
Query.prototype.run = function(sql, parameters) {
var self = this;
this.sql = sql;
......
......@@ -21,6 +21,7 @@ var Query = function(connection, sequelize, options) {
};
Utils.inherit(Query, AbstractQuery);
Query.formatBindParameters = AbstractQuery.formatBindParameters;
Query.prototype.run = function(sql, parameters) {
var self = this;
this.sql = sql;
......
......@@ -90,11 +90,11 @@ Query.prototype.parseDialectSpecificFields = parseDialectSpecificFields;
/**
* rewrite query with parameters
*/
Query.prototype.formatBindParameters = function(sql, values, dialect) {
Query.formatBindParameters = function(sql, values, dialect) {
var bindParam = [];
if (Array.isArray(values)) {
bindParam = values;
sql = this.parent.formatBindParameters(sql, values, dialect, { skipValueReplace: true })[0];
sql = AbstractQuery.formatBindParameters(sql, values, dialect, { skipValueReplace: true })[0];
} else {
var i = 0;
var seen = {};
......@@ -110,7 +110,7 @@ Query.prototype.formatBindParameters = function(sql, values, dialect) {
}
return undefined;
};
sql = this.parent.formatBindParameters(sql, values, dialect, replacementFunc)[0];
sql = AbstractQuery.formatBindParameters(sql, values, dialect, replacementFunc)[0];
}
return [sql, bindParam];
};
......
......@@ -27,14 +27,14 @@ Query.prototype.getInsertIdField = function() {
/**
* rewrite query with parameters
*/
Query.prototype.formatBindParameters = function(sql, values, dialect) {
Query.formatBindParameters = function(sql, values, dialect) {
var bindParam = [];
if (Array.isArray(values)) {
bindParam = {};
values.forEach(function(v, i) {
bindParam['$'+(i+1)] = v;
});
sql = this.parent.formatBindParameters(sql, values, dialect, { skipValueReplace: true })[0];
sql = AbstractQuery.formatBindParameters(sql, values, dialect, { skipValueReplace: true })[0];
} else {
bindParam = {};
if (typeof values === 'object') {
......@@ -42,7 +42,7 @@ Query.prototype.formatBindParameters = function(sql, values, dialect) {
bindParam['$'+k] = values[k];
});
}
sql = this.parent.formatBindParameters(sql, values, dialect, { skipValueReplace: true })[0];
sql = AbstractQuery.formatBindParameters(sql, values, dialect, { skipValueReplace: true })[0];
}
return [sql, bindParam];
};
......@@ -55,7 +55,7 @@ Query.prototype.run = function(sql, parameters) {
var method = self.getDatabaseMethod();
if (method === 'exec') {
// exec does not support bind parameter
sql = this.parent.formatBindParameters(sql, self.options.bind, self.options.dialect, { skipUnescape: true })[0];
sql = AbstractQuery.formatBindParameters(sql, self.options.bind, self.options.dialect, { skipUnescape: true })[0];
this.sql = sql;
}
......
......@@ -739,7 +739,7 @@ Sequelize.prototype.query = function(sql, options) {
}
var bindParameters;
if (options.bind) {
var bindSql = self.dialect.Query.prototype.formatBindParameters(sql, options.bind, this.options.dialect);
var bindSql = self.dialect.Query.formatBindParameters(sql, options.bind, this.options.dialect);
sql = bindSql[0];
bindParameters = bindSql[1];
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!