Skip to content

Commit

Permalink
rename id to _id so it doesn't conflict with RowDataPacket
Browse files Browse the repository at this point in the history
  • Loading branch information
lneves12 committed Jul 16, 2020
1 parent 22c2551 commit 88b44fe
Show file tree
Hide file tree
Showing 32 changed files with 36 additions and 36 deletions.
8 changes: 4 additions & 4 deletions lib/protocol/Protocol.js
Expand Up @@ -157,7 +157,7 @@ Protocol.prototype._enqueue = function(sequence) {
self._emitPacket(packet);
})
.on('timeout', function() {
var err = new Error(sequence.id + ' inactivity timeout');
var err = new Error(sequence._id + ' inactivity timeout');

err.code = 'PROTOCOL_SEQUENCE_TIMEOUT';
err.fatal = true;
Expand Down Expand Up @@ -206,7 +206,7 @@ Protocol.prototype._enqueue = function(sequence) {

Protocol.prototype._validateEnqueue = function _validateEnqueue(sequence) {
var err;
var prefix = 'Cannot enqueue ' + sequence.id;
var prefix = 'Cannot enqueue ' + sequence._id;

if (this._fatalError) {
err = new Error(prefix + ' after fatal error.');
Expand Down Expand Up @@ -253,7 +253,7 @@ Protocol.prototype._parsePacket = function() {

var Packet = this._determinePacket(sequence);
var packet = new Packet({protocol41: this._config.protocol41});
var packetName = packet.id;
var packetName = packet._id;

// Special case: Faster dispatch, and parsing done inside sequence
if (Packet === Packets.RowDataPacket) {
Expand Down Expand Up @@ -447,7 +447,7 @@ Protocol.prototype._debugPacket = function(incoming, packet) {
var direction = incoming
? '<--'
: '-->';
var packetName = packet.id;
var packetName = packet._id;
var threadId = connection && connection.threadId !== null
? ' (' + connection.threadId + ')'
: '';
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/AuthSwitchRequestPacket.js
Expand Up @@ -7,7 +7,7 @@ function AuthSwitchRequestPacket(options) {
this.authMethodData = options.authMethodData;
}

AuthSwitchRequestPacket.prototype.id = 'AuthSwitchRequestPacket';
AuthSwitchRequestPacket.prototype._id = 'AuthSwitchRequestPacket';

AuthSwitchRequestPacket.prototype.parse = function parse(parser) {
this.status = parser.parseUnsignedNumber(1);
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/AuthSwitchResponsePacket.js
Expand Up @@ -5,7 +5,7 @@ function AuthSwitchResponsePacket(options) {
this.data = options.data;
}

AuthSwitchResponsePacket.prototype.id = 'AuthSwitchResponsePacket';
AuthSwitchResponsePacket.prototype._id = 'AuthSwitchResponsePacket';

AuthSwitchResponsePacket.prototype.parse = function parse(parser) {
this.data = parser.parsePacketTerminatedBuffer();
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/ClientAuthenticationPacket.js
Expand Up @@ -14,7 +14,7 @@ function ClientAuthenticationPacket(options) {
this.protocol41 = options.protocol41;
}

ClientAuthenticationPacket.prototype.id = 'ClientAuthenticationPacket';
ClientAuthenticationPacket.prototype._id = 'ClientAuthenticationPacket';

ClientAuthenticationPacket.prototype.parse = function(parser) {
if (this.protocol41) {
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/ComChangeUserPacket.js
Expand Up @@ -9,7 +9,7 @@ function ComChangeUserPacket(options) {
this.charsetNumber = options.charsetNumber;
}

ComChangeUserPacket.prototype.id = 'ComChangeUserPacket';
ComChangeUserPacket.prototype._id = 'ComChangeUserPacket';

ComChangeUserPacket.prototype.parse = function(parser) {
this.command = parser.parseUnsignedNumber(1);
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/ComPingPacket.js
Expand Up @@ -3,7 +3,7 @@ function ComPingPacket() {
this.command = 0x0e;
}

ComPingPacket.prototype.id = 'ComPingPacket';
ComPingPacket.prototype._id = 'ComPingPacket';

ComPingPacket.prototype.write = function(writer) {
writer.writeUnsignedNumber(1, this.command);
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/ComQueryPacket.js
Expand Up @@ -4,7 +4,7 @@ function ComQueryPacket(sql) {
this.sql = sql;
}

ComQueryPacket.prototype.id = 'ComQueryPacket';
ComQueryPacket.prototype._id = 'ComQueryPacket';

ComQueryPacket.prototype.write = function(writer) {
writer.writeUnsignedNumber(1, this.command);
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/ComQuitPacket.js
Expand Up @@ -3,7 +3,7 @@ function ComQuitPacket() {
this.command = 0x01;
}

ComQuitPacket.prototype.id = 'ComQuitPacket';
ComQuitPacket.prototype._id = 'ComQuitPacket';

ComQuitPacket.prototype.parse = function parse(parser) {
this.command = parser.parseUnsignedNumber(1);
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/ComStatisticsPacket.js
Expand Up @@ -3,7 +3,7 @@ function ComStatisticsPacket() {
this.command = 0x09;
}

ComStatisticsPacket.prototype.id = 'ComStatisticsPacket';
ComStatisticsPacket.prototype._id = 'ComStatisticsPacket';

ComStatisticsPacket.prototype.write = function(writer) {
writer.writeUnsignedNumber(1, this.command);
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/EmptyPacket.js
Expand Up @@ -2,7 +2,7 @@ module.exports = EmptyPacket;
function EmptyPacket() {
}

EmptyPacket.prototype.id = 'EmptyPacket';
EmptyPacket.prototype._id = 'EmptyPacket';

EmptyPacket.prototype.parse = function parse() {
};
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/EofPacket.js
Expand Up @@ -8,7 +8,7 @@ function EofPacket(options) {
this.protocol41 = options.protocol41;
}

EofPacket.prototype.id = 'EofPacket';
EofPacket.prototype._id = 'EofPacket';

EofPacket.prototype.parse = function(parser) {
this.fieldCount = parser.parseUnsignedNumber(1);
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/ErrorPacket.js
Expand Up @@ -9,7 +9,7 @@ function ErrorPacket(options) {
this.message = options.message;
}

ErrorPacket.prototype.id = 'ErrorPacket';
ErrorPacket.prototype._id = 'ErrorPacket';

ErrorPacket.prototype.parse = function(parser) {
this.fieldCount = parser.parseUnsignedNumber(1);
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/Field.js
Expand Up @@ -13,7 +13,7 @@ function Field(options) {
this.length = options.packet.length;
}

Field.prototype.id = 'Field';
Field.prototype._id = 'Field';

Field.prototype.string = function () {
return this.parser.parseLengthCodedString();
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/FieldPacket.js
Expand Up @@ -18,7 +18,7 @@ function FieldPacket(options) {
this.protocol41 = options.protocol41;
}

FieldPacket.prototype.id = 'FieldPacket';
FieldPacket.prototype._id = 'FieldPacket';

FieldPacket.prototype.parse = function(parser) {
if (this.protocol41) {
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/HandshakeInitializationPacket.js
Expand Up @@ -27,7 +27,7 @@ function HandshakeInitializationPacket(options) {
}
}

HandshakeInitializationPacket.prototype.id = 'HandshakeInitializationPacket';
HandshakeInitializationPacket.prototype._id = 'HandshakeInitializationPacket';

HandshakeInitializationPacket.prototype.parse = function(parser) {
this.protocolVersion = parser.parseUnsignedNumber(1);
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/LocalDataFilePacket.js
Expand Up @@ -10,7 +10,7 @@ function LocalDataFilePacket(data) {
this.data = data;
}

LocalDataFilePacket.prototype.id = 'LocalDataFilePacket';
LocalDataFilePacket.prototype._id = 'LocalDataFilePacket';

LocalDataFilePacket.prototype.write = function(writer) {
writer.writeBuffer(this.data);
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/LocalInfileRequestPacket.js
Expand Up @@ -5,7 +5,7 @@ function LocalInfileRequestPacket(options) {
this.filename = options.filename;
}

LocalInfileRequestPacket.prototype.id = 'LocalInfileRequestPacket';
LocalInfileRequestPacket.prototype._id = 'LocalInfileRequestPacket';

LocalInfileRequestPacket.prototype.parse = function parse(parser) {
if (parser.parseLengthCodedNumber() !== null) {
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/OkPacket.js
Expand Up @@ -15,7 +15,7 @@ function OkPacket(options) {
this.protocol41 = options.protocol41;
}

OkPacket.prototype.id = 'OkPacket';
OkPacket.prototype._id = 'OkPacket';

OkPacket.prototype.parse = function(parser) {
this.fieldCount = parser.parseUnsignedNumber(1);
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/OldPasswordPacket.js
Expand Up @@ -5,7 +5,7 @@ function OldPasswordPacket(options) {
this.scrambleBuff = options.scrambleBuff;
}

OldPasswordPacket.prototype.id = 'OldPasswordPacket';
OldPasswordPacket.prototype._id = 'OldPasswordPacket';

OldPasswordPacket.prototype.parse = function(parser) {
this.scrambleBuff = parser.parsePacketTerminatedBuffer();
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/ResultSetHeaderPacket.js
Expand Up @@ -5,7 +5,7 @@ function ResultSetHeaderPacket(options) {
this.fieldCount = options.fieldCount;
}

ResultSetHeaderPacket.prototype.id = 'ResultSetHeaderPacket';
ResultSetHeaderPacket.prototype._id = 'ResultSetHeaderPacket';

ResultSetHeaderPacket.prototype.parse = function(parser) {
this.fieldCount = parser.parseLengthCodedNumber();
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/RowDataPacket.js
Expand Up @@ -19,7 +19,7 @@ Object.defineProperty(RowDataPacket.prototype, '_typeCast', {
value : typeCast
});

Object.defineProperty(RowDataPacket.prototype, 'id', {
Object.defineProperty(RowDataPacket.prototype, '_id', {
configurable : true,
enumerable : false,
value : 'RowDataPacket'
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/SSLRequestPacket.js
Expand Up @@ -12,7 +12,7 @@ function SSLRequestPacket(options) {
this.charsetNumber = options.charsetNumber;
}

SSLRequestPacket.prototype.id = 'SSLRequestPacket';
SSLRequestPacket.prototype._id = 'SSLRequestPacket';

SSLRequestPacket.prototype.parse = function(parser) {
// TODO: check SSLRequest packet v41 vs pre v41
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/StatisticsPacket.js
Expand Up @@ -3,7 +3,7 @@ function StatisticsPacket() {
this.message = undefined;
}

StatisticsPacket.prototype.id = 'StatisticsPacket';
StatisticsPacket.prototype._id = 'StatisticsPacket';

StatisticsPacket.prototype.parse = function(parser) {
this.message = parser.parsePacketTerminatedString();
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/packets/UseOldPasswordPacket.js
Expand Up @@ -5,7 +5,7 @@ function UseOldPasswordPacket(options) {
this.firstByte = options.firstByte || 0xfe;
}

UseOldPasswordPacket.prototype.id = 'UseOldPasswordPacket';
UseOldPasswordPacket.prototype._id = 'UseOldPasswordPacket';

UseOldPasswordPacket.prototype.parse = function(parser) {
this.firstByte = parser.parseUnsignedNumber(1);
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/sequences/ChangeUser.js
Expand Up @@ -23,7 +23,7 @@ ChangeUser.prototype.determinePacket = function determinePacket(firstByte) {
}
};

ChangeUser.prototype.id = 'ChangeUser';
ChangeUser.prototype._id = 'ChangeUser';

ChangeUser.prototype.start = function(handshakeInitializationPacket) {
var scrambleBuff = handshakeInitializationPacket.scrambleBuff();
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/sequences/Handshake.js
Expand Up @@ -33,7 +33,7 @@ Handshake.prototype.determinePacket = function determinePacket(firstByte, parser
return undefined;
};

Handshake.prototype.id = 'Handshake';
Handshake.prototype._id = 'Handshake';

Handshake.prototype['AuthSwitchRequestPacket'] = function (packet) {
var name = packet.authMethodName;
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/sequences/Ping.js
Expand Up @@ -14,7 +14,7 @@ function Ping(options, callback) {
Sequence.call(this, options, callback);
}

Ping.prototype.id = 'Ping';
Ping.prototype._id = 'Ping';

Ping.prototype.start = function() {
this.emit('packet', new Packets.ComPingPacket());
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/sequences/Query.js
Expand Up @@ -26,7 +26,7 @@ function Query(options, callback) {
this._loadError = null;
}

Query.prototype.id = 'Query';
Query.prototype._id = 'Query';

Query.prototype.start = function() {
this.emit('packet', new Packets.ComQueryPacket(this.sql));
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/sequences/Quit.js
Expand Up @@ -15,7 +15,7 @@ function Quit(options, callback) {
this._started = false;
}

Quit.prototype.id = 'Quit';
Quit.prototype._id = 'Quit';

Quit.prototype.end = function end(err) {
if (this._ended) {
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/sequences/Sequence.js
Expand Up @@ -38,7 +38,7 @@ Sequence.determinePacket = function(byte) {
}
};

Sequence.prototype.id = 'Sequence';
Sequence.prototype._id = 'Sequence';

Sequence.prototype.hasErrorHandler = function() {
return Boolean(this._callback) || listenerCount(this, 'error') > 1;
Expand Down
2 changes: 1 addition & 1 deletion lib/protocol/sequences/Statistics.js
Expand Up @@ -13,7 +13,7 @@ function Statistics(options, callback) {
Sequence.call(this, options, callback);
}

Statistics.prototype.id = 'Statistics';
Statistics.prototype._id = 'Statistics';

Statistics.prototype.start = function() {
this.emit('packet', new Packets.ComStatisticsPacket());
Expand Down
4 changes: 2 additions & 2 deletions test/FakeServer.js
Expand Up @@ -332,8 +332,8 @@ FakeConnection.prototype._parsePacket = function _parsePacket(packetHeader) {
}
break;
default:
if (!this.emit(packet.id, packet)) {
throw new Error('Unexpected packet: ' + packet.id);
if (!this.emit(packet._id, packet)) {
throw new Error('Unexpected packet: ' + packet._id);
}
}
};
Expand Down

0 comments on commit 88b44fe

Please sign in to comment.