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

You need to sign in or sign up before continuing.
Commit 721eef26 by Jan Aagaard Meier

A bit of cleanup

1 parent 2bf0668e
Showing with 7 additions and 17 deletions
...@@ -56,7 +56,7 @@ module.exports = (function() { ...@@ -56,7 +56,7 @@ module.exports = (function() {
* *
* @param {Array} data - The result of the query execution. * @param {Array} data - The result of the query execution.
*/ */
AbstractQuery.prototype.formatResults = function(data, metaData) { AbstractQuery.prototype.formatResults = function(data) {
var result = this.callee var result = this.callee
if (isInsertQuery.call(this, data)) { if (isInsertQuery.call(this, data)) {
...@@ -64,7 +64,7 @@ module.exports = (function() { ...@@ -64,7 +64,7 @@ module.exports = (function() {
} }
if (isSelectQuery.call(this)) { if (isSelectQuery.call(this)) {
result = handleSelectQuery.call(this, data, metaData) result = handleSelectQuery.call(this, data)
} else if (isShowTableQuery.call(this)) { } else if (isShowTableQuery.call(this)) {
result = handleShowTableQuery.call(this, data) result = handleShowTableQuery.call(this, data)
} else if (isShowOrDescribeQuery.call(this)) { } else if (isShowOrDescribeQuery.call(this)) {
...@@ -226,7 +226,7 @@ module.exports = (function() { ...@@ -226,7 +226,7 @@ module.exports = (function() {
return (this.sql.toLowerCase().indexOf('update') === 0) return (this.sql.toLowerCase().indexOf('update') === 0)
} }
var handleSelectQuery = function(results, metaData) { var handleSelectQuery = function(results) {
var result = null, self = this; var result = null, self = this;
if (this.options.raw) { if (this.options.raw) {
......
var mysql = require("mysql") var util = require("util")
, connection = mysql.createConnection({})
, util = require("util")
, DataTypes = require("./data-types") , DataTypes = require("./data-types")
, SqlString = require("./SqlString")
var Utils = module.exports = { var Utils = module.exports = {
_: (function() { _: (function() {
...@@ -44,10 +43,10 @@ var Utils = module.exports = { ...@@ -44,10 +43,10 @@ var Utils = module.exports = {
return s.replace(new RegExp(Utils.TICK_CHAR, 'g'), "") return s.replace(new RegExp(Utils.TICK_CHAR, 'g'), "")
}, },
escape: function(s) { escape: function(s) {
return connection.escape(s).replace(/\\"/g, '"') return SqlString.escape(s, true, "local").replace(/\\"/g, '"')
}, },
format: function(arr) { format: function(arr) {
return connection.format.apply(connection, [arr.shift(), arr]) return SqlString.format(arr.shift(), arr)
}, },
isHash: function(obj) { isHash: function(obj) {
return Utils._.isObject(obj) && !Array.isArray(obj); return Utils._.isObject(obj) && !Array.isArray(obj);
...@@ -62,15 +61,6 @@ var Utils = module.exports = { ...@@ -62,15 +61,6 @@ var Utils = module.exports = {
return s < 10 ? '0' + s : s return s < 10 ? '0' + s : s
}, },
toSqlDate: function(date) { toSqlDate: function(date) {
// return [
// [
// date.getFullYear(),
// ((date.getMonth() < 9 ? '0' : '') + (date.getMonth()+1)),
// ((date.getDate() < 10 ? '0' : '') + date.getDate())
// ].join("-"),
// date.toLocaleTimeString()
// ].join(" ")
return date.getUTCFullYear() + '-' + return date.getUTCFullYear() + '-' +
this.pad(date.getUTCMonth()+1) + '-' + this.pad(date.getUTCMonth()+1) + '-' +
this.pad(date.getUTCDate()) + ' ' + this.pad(date.getUTCDate()) + ' ' +
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!