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

Commit 721eef26 by Jan Aagaard Meier

A bit of cleanup

1 parent 2bf0668e
Showing with 8 additions and 18 deletions
......@@ -56,7 +56,7 @@ module.exports = (function() {
*
* @param {Array} data - The result of the query execution.
*/
AbstractQuery.prototype.formatResults = function(data, metaData) {
AbstractQuery.prototype.formatResults = function(data) {
var result = this.callee
if (isInsertQuery.call(this, data)) {
......@@ -64,7 +64,7 @@ module.exports = (function() {
}
if (isSelectQuery.call(this)) {
result = handleSelectQuery.call(this, data, metaData)
result = handleSelectQuery.call(this, data)
} else if (isShowTableQuery.call(this)) {
result = handleShowTableQuery.call(this, data)
} else if (isShowOrDescribeQuery.call(this)) {
......@@ -226,12 +226,12 @@ module.exports = (function() {
return (this.sql.toLowerCase().indexOf('update') === 0)
}
var handleSelectQuery = function(results, metaData) {
var handleSelectQuery = function(results) {
var result = null, self = this;
if (this.options.raw) {
result = results
} else if (this.options.hasJoin === true) {
} else if (this.options.hasJoin === true) {
result = prepareJoinData.call(this, results)
result = groupDataByCalleeFactory.call(this, result).map(function(result) {
// let's build the actual dao instance first...
......
var mysql = require("mysql")
, connection = mysql.createConnection({})
, util = require("util")
var util = require("util")
, DataTypes = require("./data-types")
, SqlString = require("./SqlString")
var Utils = module.exports = {
_: (function() {
......@@ -44,10 +43,10 @@ var Utils = module.exports = {
return s.replace(new RegExp(Utils.TICK_CHAR, 'g'), "")
},
escape: function(s) {
return connection.escape(s).replace(/\\"/g, '"')
return SqlString.escape(s, true, "local").replace(/\\"/g, '"')
},
format: function(arr) {
return connection.format.apply(connection, [arr.shift(), arr])
return SqlString.format(arr.shift(), arr)
},
isHash: function(obj) {
return Utils._.isObject(obj) && !Array.isArray(obj);
......@@ -62,15 +61,6 @@ var Utils = module.exports = {
return s < 10 ? '0' + s : s
},
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() + '-' +
this.pad(date.getUTCMonth()+1) + '-' +
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!