Skip to content

Commit 75da13a

Browse files
committed
removed id from connection messages (simplify API)
1 parent 6eea7b3 commit 75da13a

File tree

2 files changed

+2
-17
lines changed

2 files changed

+2
-17
lines changed

lib/connection.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ p.parseMessage = function() {
219219
var id = this.readChar();
220220

221221
var message = {
222-
id: id,
223222
name: messageNames[id],
224223
length: this.parseInt32()
225224
};
@@ -230,8 +229,8 @@ p.parseMessage = function() {
230229
this.lastOffset = this.offset-5;
231230
return false;
232231
}
233-
234-
return this["parse"+message.id](message);
232+
233+
return this["parse"+id](message);
235234
};
236235

237236
p.parseR = function(msg) {

test/unit/connection/inbound-parser-tests.js

-14
Original file line numberDiff line numberDiff line change
@@ -62,35 +62,30 @@ var oneFieldBuf = buffers.dataRow(['test\0']);
6262

6363
var expectedAuthenticationOkayMessage = {
6464
name: 'authenticationOk',
65-
id: 'R',
6665
length: 8
6766
};
6867

6968
var expectedParameterStatusMessage = {
7069
name: 'parameterStatus',
71-
id: 'S',
7270
length: 25,
7371
parameterName: 'client_encoding',
7472
parameterValue: 'UTF8'
7573
};
7674

7775
var expectedBackendKeyDataMessage = {
7876
name: 'backendKeyData',
79-
id: 'K',
8077
processID: 1,
8178
secretKey: 2
8279
};
8380

8481
var expectedReadyForQueryMessage = {
8582
name: 'readyForQuery',
86-
id: 'Z',
8783
length: 5,
8884
status: 'I'
8985
};
9086

9187
var expectedCommandCompleteMessage = {
9288
length: 13,
93-
id: 'C',
9489
text: "SELECT 3"
9590
};
9691
var emptyRowDescriptionBuffer = new BufferList()
@@ -99,20 +94,17 @@ var emptyRowDescriptionBuffer = new BufferList()
9994

10095
var expectedEmptyRowDescriptionMessage = {
10196
name: 'rowDescription',
102-
id: 'T',
10397
length: 6,
10498
fieldCount: 0
10599
};
106100
var expectedOneRowMessage = {
107101
name: 'rowDescription',
108-
id: 'T',
109102
length: 27,
110103
fieldCount: 1
111104
};
112105

113106
var expectedTwoRowMessage = {
114107
name: 'rowDescription',
115-
id: 'T',
116108
length: 53,
117109
fieldCount: 2
118110
};
@@ -144,18 +136,15 @@ var plainPasswordBuffer = buffers.authenticationCleartextPassword();
144136
var md5PasswordBuffer = buffers.authenticationMD5Password();
145137

146138
var expectedPlainPasswordMessage = {
147-
id: 'R',
148139
name: 'authenticationCleartextPassword'
149140
};
150141

151142
var expectedMD5PasswordMessage = {
152-
id: 'R',
153143
name: 'authenticationMD5Password'
154144
};
155145

156146
var notificationResponseBuffer = buffers.notification(4, 'hi', 'boom');
157147
var expectedNotificationResponseMessage = {
158-
id: 'A',
159148
name: 'notification',
160149
processId: 4,
161150
channel: 'hi',
@@ -183,7 +172,6 @@ test('Connection', function() {
183172

184173
test("no data message", function() {
185174
testForMessage(Buffer([0x6e, 0, 0, 0, 4]), {
186-
id: 'n',
187175
name: 'noData'
188176
});
189177
});
@@ -342,14 +330,12 @@ test('Connection', function() {
342330

343331
test('parses parse complete command', function() {
344332
testForMessage(parseCompleteBuffer, {
345-
id: '1',
346333
name: 'parseComplete'
347334
});
348335
});
349336

350337
test('parses bind complete command', function() {
351338
testForMessage(bindCompleteBuffer, {
352-
id: '2',
353339
name: 'bindComplete'
354340
});
355341
});

0 commit comments

Comments
 (0)