From dc8422ebf8f31e3a75423e769a2ebc8ebc79f34b Mon Sep 17 00:00:00 2001 From: kimwykoff Date: Mon, 28 Sep 2015 15:37:14 +0200 Subject: [PATCH] issue#49: Check that listeners exist before removing them. Also re-run coffee with version 1.9.3 --- .gitignore | 2 + lib/authentication.js | 2 +- lib/backend_message.js | 96 +++++++++++------------ lib/buffer.js | 2 +- lib/connection.js | 42 +++++----- lib/errors.js | 42 +++++----- lib/frontend_message.js | 164 ++++++++++++++++++++-------------------- lib/query.js | 75 ++++++++++-------- lib/quoting.js | 14 ++-- lib/resultset.js | 2 +- lib/starttls.js | 2 +- lib/types.js | 2 +- lib/vertica.js | 2 +- src/query.coffee | 26 ++++--- 14 files changed, 246 insertions(+), 227 deletions(-) diff --git a/.gitignore b/.gitignore index f775e1f..b9f37f7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ .DS_Store /test/connection.json dev.coffee +.idea +*.iml diff --git a/lib/authentication.js b/lib/authentication.js index 564533f..566dfdf 100644 --- a/lib/authentication.js +++ b/lib/authentication.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.9.0 +// Generated by CoffeeScript 1.9.3 var Authentication; Authentication = { diff --git a/lib/backend_message.js b/lib/backend_message.js index f6fb41b..34d00fb 100644 --- a/lib/backend_message.js +++ b/lib/backend_message.js @@ -1,7 +1,7 @@ -// Generated by CoffeeScript 1.9.0 +// Generated by CoffeeScript 1.9.3 var AuthenticationMethods, BackendMessage, messageClass, name, typeOIDs, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; AuthenticationMethods = require('./authentication').methods; @@ -20,8 +20,8 @@ BackendMessage = (function() { })(); -BackendMessage.Authentication = (function(_super) { - __extends(Authentication, _super); +BackendMessage.Authentication = (function(superClass) { + extend(Authentication, superClass); function Authentication() { return Authentication.__super__.constructor.apply(this, arguments); @@ -42,8 +42,8 @@ BackendMessage.Authentication = (function(_super) { })(BackendMessage); -BackendMessage.BackendKeyData = (function(_super) { - __extends(BackendKeyData, _super); +BackendMessage.BackendKeyData = (function(superClass) { + extend(BackendKeyData, superClass); function BackendKeyData() { return BackendKeyData.__super__.constructor.apply(this, arguments); @@ -60,8 +60,8 @@ BackendMessage.BackendKeyData = (function(_super) { })(BackendMessage); -BackendMessage.ParameterStatus = (function(_super) { - __extends(ParameterStatus, _super); +BackendMessage.ParameterStatus = (function(superClass) { + extend(ParameterStatus, superClass); function ParameterStatus() { return ParameterStatus.__super__.constructor.apply(this, arguments); @@ -78,8 +78,8 @@ BackendMessage.ParameterStatus = (function(_super) { })(BackendMessage); -BackendMessage.NotificationResponse = (function(_super) { - __extends(NotificationResponse, _super); +BackendMessage.NotificationResponse = (function(superClass) { + extend(NotificationResponse, superClass); function NotificationResponse() { return NotificationResponse.__super__.constructor.apply(this, arguments); @@ -97,8 +97,8 @@ BackendMessage.NotificationResponse = (function(_super) { })(BackendMessage); -BackendMessage.EmptyQueryResponse = (function(_super) { - __extends(EmptyQueryResponse, _super); +BackendMessage.EmptyQueryResponse = (function(superClass) { + extend(EmptyQueryResponse, superClass); function EmptyQueryResponse() { return EmptyQueryResponse.__super__.constructor.apply(this, arguments); @@ -110,8 +110,8 @@ BackendMessage.EmptyQueryResponse = (function(_super) { })(BackendMessage); -BackendMessage.RowDescription = (function(_super) { - __extends(RowDescription, _super); +BackendMessage.RowDescription = (function(superClass) { + extend(RowDescription, superClass); function RowDescription() { return RowDescription.__super__.constructor.apply(this, arguments); @@ -120,11 +120,11 @@ BackendMessage.RowDescription = (function(_super) { RowDescription.prototype.typeId = 84; RowDescription.prototype.read = function(buffer) { - var fieldDescriptor, formatCode, i, modifier, name, numberOfFields, pos, size, tableFieldIndex, tableOID, typeOID, _i; + var fieldDescriptor, formatCode, i, j, modifier, name, numberOfFields, pos, ref, size, tableFieldIndex, tableOID, typeOID; numberOfFields = buffer.readUInt16BE(0); pos = 2; this.columns = []; - for (i = _i = 0; 0 <= numberOfFields ? _i < numberOfFields : _i > numberOfFields; i = 0 <= numberOfFields ? ++_i : --_i) { + for (i = j = 0, ref = numberOfFields; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) { name = buffer.readZeroTerminatedString(pos); pos += Buffer.byteLength(name) + 1; tableOID = buffer.readUInt32BE(pos); @@ -158,8 +158,8 @@ BackendMessage.RowDescription = (function(_super) { })(BackendMessage); -BackendMessage.DataRow = (function(_super) { - __extends(DataRow, _super); +BackendMessage.DataRow = (function(superClass) { + extend(DataRow, superClass); function DataRow() { return DataRow.__super__.constructor.apply(this, arguments); @@ -168,11 +168,11 @@ BackendMessage.DataRow = (function(_super) { DataRow.prototype.typeId = 68; DataRow.prototype.read = function(buffer) { - var data, i, length, numberOfFields, pos, _i; + var data, i, j, length, numberOfFields, pos, ref; numberOfFields = buffer.readUInt16BE(0); pos = 2; this.values = []; - for (i = _i = 0; 0 <= numberOfFields ? _i < numberOfFields : _i > numberOfFields; i = 0 <= numberOfFields ? ++_i : --_i) { + for (i = j = 0, ref = numberOfFields; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) { length = buffer.readUInt32BE(pos); pos += 4; if (length === 4294967295) { @@ -190,8 +190,8 @@ BackendMessage.DataRow = (function(_super) { })(BackendMessage); -BackendMessage.CommandComplete = (function(_super) { - __extends(CommandComplete, _super); +BackendMessage.CommandComplete = (function(superClass) { + extend(CommandComplete, superClass); function CommandComplete() { return CommandComplete.__super__.constructor.apply(this, arguments); @@ -207,8 +207,8 @@ BackendMessage.CommandComplete = (function(_super) { })(BackendMessage); -BackendMessage.CloseComplete = (function(_super) { - __extends(CloseComplete, _super); +BackendMessage.CloseComplete = (function(superClass) { + extend(CloseComplete, superClass); function CloseComplete() { return CloseComplete.__super__.constructor.apply(this, arguments); @@ -220,8 +220,8 @@ BackendMessage.CloseComplete = (function(_super) { })(BackendMessage); -BackendMessage.ParameterDescription = (function(_super) { - __extends(ParameterDescription, _super); +BackendMessage.ParameterDescription = (function(superClass) { + extend(ParameterDescription, superClass); function ParameterDescription() { return ParameterDescription.__super__.constructor.apply(this, arguments); @@ -233,12 +233,12 @@ BackendMessage.ParameterDescription = (function(_super) { var count, i; count = buffer.readUInt16BE(0); return this.parameterTypes = (function() { - var _i, _results; - _results = []; - for (i = _i = 0; 0 <= count ? _i < count : _i > count; i = 0 <= count ? ++_i : --_i) { - _results.push(buffer.readUInt32BE(2 + i * 4)); + var j, ref, results; + results = []; + for (i = j = 0, ref = count; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) { + results.push(buffer.readUInt32BE(2 + i * 4)); } - return _results; + return results; })(); }; @@ -246,8 +246,8 @@ BackendMessage.ParameterDescription = (function(_super) { })(BackendMessage); -BackendMessage.ParseComplete = (function(_super) { - __extends(ParseComplete, _super); +BackendMessage.ParseComplete = (function(superClass) { + extend(ParseComplete, superClass); function ParseComplete() { return ParseComplete.__super__.constructor.apply(this, arguments); @@ -259,8 +259,8 @@ BackendMessage.ParseComplete = (function(_super) { })(BackendMessage); -BackendMessage.ErrorResponse = (function(_super) { - __extends(ErrorResponse, _super); +BackendMessage.ErrorResponse = (function(superClass) { + extend(ErrorResponse, superClass); function ErrorResponse() { return ErrorResponse.__super__.constructor.apply(this, arguments); @@ -302,8 +302,8 @@ BackendMessage.ErrorResponse = (function(_super) { })(BackendMessage); -BackendMessage.NoticeResponse = (function(_super) { - __extends(NoticeResponse, _super); +BackendMessage.NoticeResponse = (function(superClass) { + extend(NoticeResponse, superClass); function NoticeResponse() { return NoticeResponse.__super__.constructor.apply(this, arguments); @@ -315,8 +315,8 @@ BackendMessage.NoticeResponse = (function(_super) { })(BackendMessage.ErrorResponse); -BackendMessage.ReadyForQuery = (function(_super) { - __extends(ReadyForQuery, _super); +BackendMessage.ReadyForQuery = (function(superClass) { + extend(ReadyForQuery, superClass); function ReadyForQuery() { return ReadyForQuery.__super__.constructor.apply(this, arguments); @@ -332,8 +332,8 @@ BackendMessage.ReadyForQuery = (function(_super) { })(BackendMessage); -BackendMessage.CopyFileResponse = (function(_super) { - __extends(CopyFileResponse, _super); +BackendMessage.CopyFileResponse = (function(superClass) { + extend(CopyFileResponse, superClass); function CopyFileResponse() { return CopyFileResponse.__super__.constructor.apply(this, arguments); @@ -342,11 +342,11 @@ BackendMessage.CopyFileResponse = (function(_super) { CopyFileResponse.prototype.typeId = 70; CopyFileResponse.prototype.read = function(buffer) { - var filename, i, last, numberOfFiles, pos, _i; + var filename, i, j, last, numberOfFiles, pos, ref; this.files = []; numberOfFiles = buffer.readUInt16BE(0); pos = 2; - for (i = _i = 0; 0 <= numberOfFiles ? _i < numberOfFiles : _i > numberOfFiles; i = 0 <= numberOfFiles ? ++_i : --_i) { + for (i = j = 0, ref = numberOfFiles; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) { filename = buffer.readZeroTerminatedString(pos); this.files.push(filename); pos += filename.length + 1; @@ -358,8 +358,8 @@ BackendMessage.CopyFileResponse = (function(_super) { })(BackendMessage); -BackendMessage.CopyInResponse = (function(_super) { - __extends(CopyInResponse, _super); +BackendMessage.CopyInResponse = (function(superClass) { + extend(CopyInResponse, superClass); function CopyInResponse() { return CopyInResponse.__super__.constructor.apply(this, arguments); @@ -368,12 +368,12 @@ BackendMessage.CopyInResponse = (function(_super) { CopyInResponse.prototype.typeId = 71; CopyInResponse.prototype.read = function(buffer) { - var i, numberOfFields, pos, _i; + var i, j, numberOfFields, pos, ref; this.globalFormatType = buffer.readUInt8(0); this.fieldFormatTypes = []; numberOfFields = buffer.readUInt16BE(1); pos = 3; - for (i = _i = 0; 0 <= numberOfFields ? _i < numberOfFields : _i > numberOfFields; i = 0 <= numberOfFields ? ++_i : --_i) { + for (i = j = 0, ref = numberOfFields; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) { this.fieldFormatTypes.push(buffer.readUInt8(pos)); pos += 1; } diff --git a/lib/buffer.js b/lib/buffer.js index 997a01e..aabc326 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.9.0 +// Generated by CoffeeScript 1.9.3 var Buffer; Buffer = require('buffer').Buffer; diff --git a/lib/connection.js b/lib/connection.js index 7b0d65c..82e91b5 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -1,7 +1,7 @@ -// Generated by CoffeeScript 1.9.0 +// Generated by CoffeeScript 1.9.3 var Authentication, BackendMessage, Connection, EventEmitter, FrontendMessage, Query, errors, net, util, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; util = require('util'); @@ -19,20 +19,20 @@ Query = require('./query'); errors = require('./errors'); -Connection = (function(_super) { - __extends(Connection, _super); +Connection = (function(superClass) { + extend(Connection, superClass); - function Connection(_at_connectionOptions) { - var _base, _base1, _base2; - this.connectionOptions = _at_connectionOptions; - if ((_base = this.connectionOptions).host == null) { - _base.host = 'localhost'; + function Connection(connectionOptions) { + var base, base1, base2; + this.connectionOptions = connectionOptions; + if ((base = this.connectionOptions).host == null) { + base.host = 'localhost'; } - if ((_base1 = this.connectionOptions).port == null) { - _base1.port = 5433; + if ((base1 = this.connectionOptions).port == null) { + base1.port = 5433; } - if ((_base2 = this.connectionOptions).ssl == null) { - _base2.ssl = 'optional'; + if ((base2 = this.connectionOptions).ssl == null) { + base2.ssl = 'optional'; } this.connected = false; this.busy = true; @@ -220,8 +220,8 @@ Connection = (function(_super) { })(this)); this.on('BackendKeyData', (function(_this) { return function(msg) { - var _ref; - return _ref = [msg.pid, msg.key], _this.pid = _ref[0], _this.key = _ref[1], _ref; + var ref; + return ref = [msg.pid, msg.key], _this.pid = ref[0], _this.key = ref[1], ref; }; })(this)); return this.on('ReadyForQuery', (function(_this) { @@ -234,7 +234,7 @@ Connection = (function(_super) { }; Connection.prototype._initializeConnection = function() { - var chain, initializer, initializers, _i, _len; + var chain, i, initializer, initializers, len; initializers = []; if (!this.connectionOptions.skipInitialization) { if (this.connectionOptions.interruptible) { @@ -254,8 +254,8 @@ Connection = (function(_super) { } } chain = this._initializationSuccess.bind(this); - for (_i = 0, _len = initializers.length; _i < _len; _i++) { - initializer = initializers[_i]; + for (i = 0, len = initializers.length; i < len; i++) { + initializer = initializers[i]; chain = initializer.bind(this, chain, this._initializationFailure.bind(this)); } return chain(); @@ -378,8 +378,8 @@ Connection = (function(_super) { }; Connection.prototype._onError = function(err) { - var error, _ref; - error = new errors.ConnectionError((_ref = err.message) != null ? _ref : err.toString()); + var error, ref; + error = new errors.ConnectionError((ref = err.message) != null ? ref : err.toString()); if (this.currentJob) { this.currentJob.onConnectionError(error); } diff --git a/lib/errors.js b/lib/errors.js index 52183bb..e1ad260 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -1,12 +1,12 @@ -// Generated by CoffeeScript 1.9.0 -var __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; +// Generated by CoffeeScript 1.9.3 +var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; -exports.VerticaError = (function(_super) { - __extends(VerticaError, _super); +exports.VerticaError = (function(superClass) { + extend(VerticaError, superClass); - function VerticaError(_at_message) { - this.message = _at_message; + function VerticaError(message) { + this.message = message; VerticaError.__super__.constructor.call(this, this.message); } @@ -14,8 +14,8 @@ exports.VerticaError = (function(_super) { })(Error); -exports.ConnectionError = (function(_super) { - __extends(ConnectionError, _super); +exports.ConnectionError = (function(superClass) { + extend(ConnectionError, superClass); function ConnectionError() { return ConnectionError.__super__.constructor.apply(this, arguments); @@ -25,8 +25,8 @@ exports.ConnectionError = (function(_super) { })(exports.VerticaError); -exports.ConnectionErrorResponse = (function(_super) { - __extends(ConnectionErrorResponse, _super); +exports.ConnectionErrorResponse = (function(superClass) { + extend(ConnectionErrorResponse, superClass); function ConnectionErrorResponse(msg) { ConnectionErrorResponse.__super__.constructor.call(this, msg.information['Message']); @@ -38,8 +38,8 @@ exports.ConnectionErrorResponse = (function(_super) { })(exports.ConnectionError); -exports.AuthenticationError = (function(_super) { - __extends(AuthenticationError, _super); +exports.AuthenticationError = (function(superClass) { + extend(AuthenticationError, superClass); function AuthenticationError() { return AuthenticationError.__super__.constructor.apply(this, arguments); @@ -49,8 +49,8 @@ exports.AuthenticationError = (function(_super) { })(exports.ConnectionErrorResponse); -exports.SSLError = (function(_super) { - __extends(SSLError, _super); +exports.SSLError = (function(superClass) { + extend(SSLError, superClass); function SSLError() { return SSLError.__super__.constructor.apply(this, arguments); @@ -60,8 +60,8 @@ exports.SSLError = (function(_super) { })(exports.ConnectionError); -exports.ClientStateError = (function(_super) { - __extends(ClientStateError, _super); +exports.ClientStateError = (function(superClass) { + extend(ClientStateError, superClass); function ClientStateError() { return ClientStateError.__super__.constructor.apply(this, arguments); @@ -71,8 +71,8 @@ exports.ClientStateError = (function(_super) { })(exports.VerticaError); -exports.QueryError = (function(_super) { - __extends(QueryError, _super); +exports.QueryError = (function(superClass) { + extend(QueryError, superClass); function QueryError() { return QueryError.__super__.constructor.apply(this, arguments); @@ -82,8 +82,8 @@ exports.QueryError = (function(_super) { })(exports.VerticaError); -exports.QueryErrorResponse = (function(_super) { - __extends(QueryErrorResponse, _super); +exports.QueryErrorResponse = (function(superClass) { + extend(QueryErrorResponse, superClass); function QueryErrorResponse(msg) { QueryErrorResponse.__super__.constructor.call(this, msg.information['Message']); diff --git a/lib/frontend_message.js b/lib/frontend_message.js index d58b777..f3abc1e 100644 --- a/lib/frontend_message.js +++ b/lib/frontend_message.js @@ -1,8 +1,8 @@ -// Generated by CoffeeScript 1.9.0 +// Generated by CoffeeScript 1.9.3 var Authentication, Buffer, FrontendMessage, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty, - __slice = [].slice; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty, + slice = [].slice; Authentication = require('./authentication'); @@ -43,17 +43,17 @@ FrontendMessage = (function() { })(); -FrontendMessage.Startup = (function(_super) { - __extends(Startup, _super); +FrontendMessage.Startup = (function(superClass) { + extend(Startup, superClass); Startup.prototype.typeId = null; Startup.prototype.protocol = 3 << 16; - function Startup(_at_user, _at_database, _at_options) { - this.user = _at_user; - this.database = _at_database; - this.options = _at_options; + function Startup(user, database, options) { + this.user = user; + this.database = database; + this.options = options; } Startup.prototype.payload = function() { @@ -83,8 +83,8 @@ FrontendMessage.Startup = (function(_super) { })(FrontendMessage); -FrontendMessage.SSLRequest = (function(_super) { - __extends(SSLRequest, _super); +FrontendMessage.SSLRequest = (function(superClass) { + extend(SSLRequest, superClass); function SSLRequest() { return SSLRequest.__super__.constructor.apply(this, arguments); @@ -105,15 +105,15 @@ FrontendMessage.SSLRequest = (function(_super) { })(FrontendMessage); -FrontendMessage.Password = (function(_super) { - __extends(Password, _super); +FrontendMessage.Password = (function(superClass) { + extend(Password, superClass); Password.prototype.typeId = 112; - function Password(_at_password, _at_authMethod, _at_options) { - this.password = _at_password; - this.authMethod = _at_authMethod; - this.options = _at_options; + function Password(password, authMethod, options) { + this.password = password; + this.authMethod = authMethod; + this.options = options; if (this.password == null) { this.password = ''; } @@ -126,11 +126,11 @@ FrontendMessage.Password = (function(_super) { } Password.prototype.md5 = function() { - var hash, value, values, _i, _len; - values = 1 <= arguments.length ? __slice.call(arguments, 0) : []; + var hash, i, len, value, values; + values = 1 <= arguments.length ? slice.call(arguments, 0) : []; hash = require('crypto').createHash('md5'); - for (_i = 0, _len = values.length; _i < _len; _i++) { - value = values[_i]; + for (i = 0, len = values.length; i < len; i++) { + value = values[i]; hash.update(value); } return hash.digest('hex'); @@ -158,14 +158,14 @@ FrontendMessage.Password = (function(_super) { })(FrontendMessage); -FrontendMessage.CancelRequest = (function(_super) { - __extends(CancelRequest, _super); +FrontendMessage.CancelRequest = (function(superClass) { + extend(CancelRequest, superClass); CancelRequest.prototype.cancelRequestMagicNumber = 80877102; - function CancelRequest(_at_backendPid, _at_backendKey) { - this.backendPid = _at_backendPid; - this.backendKey = _at_backendKey; + function CancelRequest(backendPid, backendKey) { + this.backendPid = backendPid; + this.backendKey = backendKey; } CancelRequest.prototype.payload = function() { @@ -181,13 +181,13 @@ FrontendMessage.CancelRequest = (function(_super) { })(FrontendMessage); -FrontendMessage.Close = (function(_super) { - __extends(Close, _super); +FrontendMessage.Close = (function(superClass) { + extend(Close, superClass); Close.prototype.typeId = 67; - function Close(type, _at_name) { - this.name = _at_name; + function Close(type, name) { + this.name = name; if (this.name == null) { this.name = ""; } @@ -223,13 +223,13 @@ FrontendMessage.Close = (function(_super) { })(FrontendMessage); -FrontendMessage.Describe = (function(_super) { - __extends(Describe, _super); +FrontendMessage.Describe = (function(superClass) { + extend(Describe, superClass); Describe.prototype.typeId = 68; - function Describe(type, _at_name) { - this.name = _at_name; + function Describe(type, name) { + this.name = name; if (this.name == null) { this.name = ""; } @@ -263,14 +263,14 @@ FrontendMessage.Describe = (function(_super) { })(FrontendMessage); -FrontendMessage.Execute = (function(_super) { - __extends(Execute, _super); +FrontendMessage.Execute = (function(superClass) { + extend(Execute, superClass); Execute.prototype.typeId = 69; - function Execute(_at_portal, _at_maxRows) { - this.portal = _at_portal; - this.maxRows = _at_maxRows; + function Execute(portal, maxRows) { + this.portal = portal; + this.maxRows = maxRows; if (this.portal == null) { this.portal = ""; } @@ -291,13 +291,13 @@ FrontendMessage.Execute = (function(_super) { })(FrontendMessage); -FrontendMessage.Query = (function(_super) { - __extends(Query, _super); +FrontendMessage.Query = (function(superClass) { + extend(Query, superClass); Query.prototype.typeId = 81; - function Query(_at_sql) { - this.sql = _at_sql; + function Query(sql) { + this.sql = sql; } Query.prototype.payload = function() { @@ -308,15 +308,15 @@ FrontendMessage.Query = (function(_super) { })(FrontendMessage); -FrontendMessage.Parse = (function(_super) { - __extends(Parse, _super); +FrontendMessage.Parse = (function(superClass) { + extend(Parse, superClass); Parse.prototype.typeId = 80; - function Parse(_at_name, _at_sql, _at_parameterTypes) { - this.name = _at_name; - this.sql = _at_sql; - this.parameterTypes = _at_parameterTypes; + function Parse(name, sql, parameterTypes) { + this.name = name; + this.sql = sql; + this.parameterTypes = parameterTypes; if (this.name == null) { this.name = ""; } @@ -326,15 +326,15 @@ FrontendMessage.Parse = (function(_super) { } Parse.prototype.payload = function() { - var b, paramType, pos, _i, _len, _ref; + var b, i, len, paramType, pos, ref; b = new Buffer(8192); pos = b.writeZeroTerminatedString(this.name, 0); pos += b.writeZeroTerminatedString(this.sql, pos); b.writeUInt16BE(this.parameterTypes.length, pos); pos += 2; - _ref = this.parameterTypes; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - paramType = _ref[_i]; + ref = this.parameterTypes; + for (i = 0, len = ref.length; i < len; i++) { + paramType = ref[i]; b.writeUInt32BE(paramType, pos); pos += 4; } @@ -345,24 +345,24 @@ FrontendMessage.Parse = (function(_super) { })(FrontendMessage); -FrontendMessage.Bind = (function(_super) { - __extends(Bind, _super); +FrontendMessage.Bind = (function(superClass) { + extend(Bind, superClass); Bind.prototype.typeId = 66; - function Bind(_at_portal, _at_preparedStatement, parameterValues) { - var parameterValue, _i, _len; - this.portal = _at_portal; - this.preparedStatement = _at_preparedStatement; + function Bind(portal, preparedStatement, parameterValues) { + var i, len, parameterValue; + this.portal = portal; + this.preparedStatement = preparedStatement; this.parameterValues = []; - for (_i = 0, _len = parameterValues.length; _i < _len; _i++) { - parameterValue = parameterValues[_i]; + for (i = 0, len = parameterValues.length; i < len; i++) { + parameterValue = parameterValues[i]; this.parameterValues.push(parameterValue.toString()); } } Bind.prototype.payload = function() { - var b, pos, value, _i, _len, _ref; + var b, i, len, pos, ref, value; b = new Buffer(8192); pos = 0; pos += b.writeZeroTerminatedString(this.portal, pos); @@ -370,9 +370,9 @@ FrontendMessage.Bind = (function(_super) { b.writeUInt16BE(0x00, pos); b.writeUInt16BE(this.parameterValues.length, pos + 2); pos += 4; - _ref = this.parameterValues; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - value = _ref[_i]; + ref = this.parameterValues; + for (i = 0, len = ref.length; i < len; i++) { + value = ref[i]; b.writeUInt32BE(value.length, pos); pos += 4; pos += b.write(value, pos); @@ -384,8 +384,8 @@ FrontendMessage.Bind = (function(_super) { })(FrontendMessage); -FrontendMessage.Flush = (function(_super) { - __extends(Flush, _super); +FrontendMessage.Flush = (function(superClass) { + extend(Flush, superClass); function Flush() { return Flush.__super__.constructor.apply(this, arguments); @@ -397,8 +397,8 @@ FrontendMessage.Flush = (function(_super) { })(FrontendMessage); -FrontendMessage.Sync = (function(_super) { - __extends(Sync, _super); +FrontendMessage.Sync = (function(superClass) { + extend(Sync, superClass); function Sync() { return Sync.__super__.constructor.apply(this, arguments); @@ -410,8 +410,8 @@ FrontendMessage.Sync = (function(_super) { })(FrontendMessage); -FrontendMessage.Terminate = (function(_super) { - __extends(Terminate, _super); +FrontendMessage.Terminate = (function(superClass) { + extend(Terminate, superClass); function Terminate() { return Terminate.__super__.constructor.apply(this, arguments); @@ -423,13 +423,13 @@ FrontendMessage.Terminate = (function(_super) { })(FrontendMessage); -FrontendMessage.CopyData = (function(_super) { - __extends(CopyData, _super); +FrontendMessage.CopyData = (function(superClass) { + extend(CopyData, superClass); CopyData.prototype.typeId = 100; - function CopyData(_at_data) { - this.data = _at_data; + function CopyData(data) { + this.data = data; } CopyData.prototype.payload = function() { @@ -440,8 +440,8 @@ FrontendMessage.CopyData = (function(_super) { })(FrontendMessage); -FrontendMessage.CopyDone = (function(_super) { - __extends(CopyDone, _super); +FrontendMessage.CopyDone = (function(superClass) { + extend(CopyDone, superClass); function CopyDone() { return CopyDone.__super__.constructor.apply(this, arguments); @@ -453,13 +453,13 @@ FrontendMessage.CopyDone = (function(_super) { })(FrontendMessage); -FrontendMessage.CopyFail = (function(_super) { - __extends(CopyFail, _super); +FrontendMessage.CopyFail = (function(superClass) { + extend(CopyFail, superClass); CopyFail.prototype.typeId = 102; - function CopyFail(_at_error) { - this.error = _at_error; + function CopyFail(error) { + this.error = error; } CopyFail.prototype.payload = function() { diff --git a/lib/query.js b/lib/query.js index b329f9f..a9b412c 100644 --- a/lib/query.js +++ b/lib/query.js @@ -1,7 +1,7 @@ -// Generated by CoffeeScript 1.9.0 +// Generated by CoffeeScript 1.9.3 var EventEmitter, FrontendMessage, Query, Resultset, decoders, errors, - __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - __hasProp = {}.hasOwnProperty; + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; EventEmitter = require('events').EventEmitter; @@ -13,13 +13,13 @@ Resultset = require('./resultset'); errors = require('./errors'); -Query = (function(_super) { - __extends(Query, _super); +Query = (function(superClass) { + extend(Query, superClass); - function Query(_at_connection, _at_sql, _at_callback) { - this.connection = _at_connection; - this.sql = _at_sql; - this.callback = _at_callback; + function Query(connection, sql, callback1) { + this.connection = connection; + this.sql = sql; + this.callback = callback1; this._handlingCopyIn = false; } @@ -47,25 +47,25 @@ Query = (function(_super) { }; Query.prototype.onRowDescription = function(msg) { - var column, customDecoders, decoder, field, type, _i, _len, _ref, _ref1, _ref2; + var column, customDecoders, decoder, field, i, len, ref, ref1, ref2, type; if ((this.callback != null) && (this.status != null)) { throw new errors.VerticaError("Cannot handle multi-queries with a callback!"); } customDecoders = {}; - _ref = this.connection.connectionOptions.decoders; - for (type in _ref) { - decoder = _ref[type]; + ref = this.connection.connectionOptions.decoders; + for (type in ref) { + decoder = ref[type]; customDecoders[type] = decoder; } - _ref1 = this.decoders; - for (type in _ref1) { - decoder = _ref1[type]; + ref1 = this.decoders; + for (type in ref1) { + decoder = ref1[type]; customDecoders[type] = decoder; } this.fields = []; - _ref2 = msg.columns; - for (_i = 0, _len = _ref2.length; _i < _len; _i++) { - column = _ref2[_i]; + ref2 = msg.columns; + for (i = 0, len = ref2.length; i < len; i++) { + column = ref2[i]; field = new Query.Field(column, customDecoders); this.emit('field', field); this.fields.push(field); @@ -77,11 +77,11 @@ Query = (function(_super) { }; Query.prototype.onDataRow = function(msg) { - var index, row, value, _i, _len, _ref; + var i, index, len, ref, row, value; row = []; - _ref = msg.values; - for (index = _i = 0, _len = _ref.length; _i < _len; index = ++_i) { - value = _ref[index]; + ref = msg.values; + for (index = i = 0, len = ref.length; i < len; index = ++i) { + value = ref[index]; row.push(value != null ? this.fields[index].decoder(value) : null); } if (this.callback) { @@ -227,9 +227,9 @@ Query = (function(_super) { }; Query.prototype.copyFail = function(error, callback) { - var message, _ref; + var message, ref; if (this._handlingCopyIn) { - message = (_ref = error.message) != null ? _ref : error.toString(); + message = (ref = error.message) != null ? ref : error.toString(); this.connection._writeMessage(new FrontendMessage.CopyFail(message), callback); return this._handlingCopyIn = false; } else { @@ -238,14 +238,23 @@ Query = (function(_super) { }; Query.prototype._removeAllListeners = function() { - this.connection.removeListener('EmptyQueryResponse', this.onEmptyQueryListener); - this.connection.removeListener('RowDescription', this.onRowDescriptionListener); - this.connection.removeListener('DataRow', this.onDataRowListener); - this.connection.removeListener('CommandComplete', this.onCommandCompleteListener); - this.connection.removeListener('ErrorResponse', this.onErrorResponseListener); - this.connection.removeListener('ReadyForQuery', this.onReadyForQueryListener); - this.connection.removeListener('CopyInResponse', this.onCopyInResponseListener); - return this.connection.removeListener('CopyFileResponse', this.onCopyFileResponseListener); + var listeners; + listeners = { + 'EmptyQueryResponse': this.onEmptyQueryListener, + 'RowDescription': this.onRowDescriptionListener, + 'DataRow': this.onDataRowListener, + 'CommandComplete': this.onCommandCompleteListener, + 'ErrorResponse': this.onErrorResponseListener, + 'ReadyForQuery': this.onReadyForQueryListener, + 'CopyInResponse': this.onCopyInResponseListener, + 'CopyFileResponse': this.onCopyFileResponseListener + }; + for (var key in listeners) { + if (typeof listeners[key] !== "undefined" && listeners[key] !== null) { + this.connection.removeListener(key, listeners[key]) + } + }; + return listeners; }; return Query; diff --git a/lib/quoting.js b/lib/quoting.js index f459ad2..1d90c96 100644 --- a/lib/quoting.js +++ b/lib/quoting.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.9.0 +// Generated by CoffeeScript 1.9.3 exports.escape = function(val) { return val.toString().replace(/'/g, "''"); }; @@ -19,13 +19,13 @@ exports.quote = function(val) { return "'" + (exports.escape(val)) + "'"; } else if (val instanceof Array) { return ((function() { - var _i, _len, _results; - _results = []; - for (_i = 0, _len = val.length; _i < _len; _i++) { - v = val[_i]; - _results.push(exports.quote(v)); + var i, len, results; + results = []; + for (i = 0, len = val.length; i < len; i++) { + v = val[i]; + results.push(exports.quote(v)); } - return _results; + return results; })()).join(', '); } else if (val instanceof Date) { return "'" + (val.toISOString().replace(/T/, ' ').replace(/\.\d+Z$/, '')) + "'::timestamp"; diff --git a/lib/resultset.js b/lib/resultset.js index 905096d..c3726d8 100644 --- a/lib/resultset.js +++ b/lib/resultset.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.9.0 +// Generated by CoffeeScript 1.9.3 var Resultset; Resultset = (function() { diff --git a/lib/starttls.js b/lib/starttls.js index 5ad552a..f37bd64 100644 --- a/lib/starttls.js +++ b/lib/starttls.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.9.0 +// Generated by CoffeeScript 1.9.3 var pipe; module.exports = function(socket, options, cb) { diff --git a/lib/types.js b/lib/types.js index 4b8a50d..02e68ae 100644 --- a/lib/types.js +++ b/lib/types.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.9.0 +// Generated by CoffeeScript 1.9.3 var VerticaDate, VerticaInterval, VerticaTime, VerticaTimestamp, binaryDecoders, binaryEncoders, padWithZeroes, stringDecoders, stringEncoders; padWithZeroes = function(str, length) { diff --git a/lib/vertica.js b/lib/vertica.js index 17f9c28..a98c5fe 100644 --- a/lib/vertica.js +++ b/lib/vertica.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.9.0 +// Generated by CoffeeScript 1.9.3 var quoting, types; exports.Connection = require('./connection'); diff --git a/src/query.coffee b/src/query.coffee index deed07a..2654158 100644 --- a/src/query.coffee +++ b/src/query.coffee @@ -158,15 +158,23 @@ class Query extends EventEmitter throw new errors.ClientStateError("Copy in mode not active!") _removeAllListeners: () -> - @connection.removeListener 'EmptyQueryResponse', @onEmptyQueryListener - @connection.removeListener 'RowDescription', @onRowDescriptionListener - @connection.removeListener 'DataRow', @onDataRowListener - @connection.removeListener 'CommandComplete', @onCommandCompleteListener - @connection.removeListener 'ErrorResponse', @onErrorResponseListener - @connection.removeListener 'ReadyForQuery', @onReadyForQueryListener - @connection.removeListener 'CopyInResponse', @onCopyInResponseListener - @connection.removeListener 'CopyFileResponse', @onCopyFileResponseListener - + listeners = { + 'EmptyQueryResponse': @onEmptyQueryListener, + 'RowDescription': @onRowDescriptionListener, + 'DataRow': @onDataRowListener, + 'CommandComplete': @onCommandCompleteListener, + 'ErrorResponse': @onErrorResponseListener, + 'ReadyForQuery': @onReadyForQueryListener, + 'CopyInResponse': @onCopyInResponseListener, + 'CopyFileResponse': @onCopyFileResponseListener + }; + + `for (var key in listeners) { + if (typeof listeners[key] !== "undefined" && listeners[key] !== null) { + this.connection.removeListener(key, listeners[key]) + } + }` + listeners class Query.Field constructor: (msg, customDecoders) ->