From e69048159c33727ca1c5d375d2d2edc5148fa8df Mon Sep 17 00:00:00 2001 From: Sasha Aliashkevich Date: Mon, 12 Dec 2016 09:47:41 +0100 Subject: [PATCH] Remove parsing datatypes; result.cmdStatus added Remove parsing datatypes in order to keep all the values as strings. This is not compatible commit with an upstream version of driver. cmdStatus shows the state of the command returned by Postgers. It's useful to detect what type of command was executed (SELECT vs INSERT etc) --- lib/result.js | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/result.js b/lib/result.js index 7dfd116f0..744983b96 100644 --- a/lib/result.js +++ b/lib/result.js @@ -22,6 +22,7 @@ var Result = function (rowMode) { this._parsers = [] this.RowCtor = null this.rowAsArray = rowMode === 'array' + this.cmdStatus = null; if (this.rowAsArray) { this.parseRow = this._parseRowAsArray } @@ -29,12 +30,13 @@ var Result = function (rowMode) { var matchRegexp = /^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/ -// adds a command complete message -Result.prototype.addCommandComplete = function (msg) { - var match - if (msg.text) { - // pure javascript - match = matchRegexp.exec(msg.text) +//adds a command complete message +Result.prototype.addCommandComplete = function(msg) { + this.cmdStatus = msg.text; + var match; + if(msg.text) { + //pure javascript + match = matchRegexp.exec(msg.text); } else { // native bindings match = matchRegexp.exec(msg.command) @@ -52,15 +54,11 @@ Result.prototype.addCommandComplete = function (msg) { } } -Result.prototype._parseRowAsArray = function (rowData) { - var row = [] - for (var i = 0, len = rowData.length; i < len; i++) { - var rawValue = rowData[i] - if (rawValue !== null) { - row.push(this._parsers[i](rawValue)) - } else { - row.push(null) - } +Result.prototype._parseRowAsArray = function(rowData) { + var row = []; + for(var i = 0, len = rowData.length; i < len; i++) { + var rawValue = rowData[i]; + row.push(rawValue); } return row }