Skip to content

Commit 5fff5fc

Browse files
committed
Added integration test for overriding type parsers on a per-client basis.
1 parent e2ea482 commit 5fff5fc

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
var helper = require(__dirname + '/test-helper');
2+
3+
function testTypeParser(client, expectedResult, done) {
4+
var boolValue = true;
5+
client.query('CREATE TEMP TABLE parserOverrideTest(id bool)');
6+
client.query('INSERT INTO parserOverrideTest(id) VALUES ($1)', [boolValue]);
7+
client.query('SELECT * FROM parserOverrideTest', assert.success(function(result) {
8+
assert.equal(result.rows[0].id, expectedResult);
9+
helper.pg.end();
10+
done();
11+
}));
12+
}
13+
14+
helper.pg.connect(helper.config, assert.success(function(client1, done1) {
15+
helper.pg.connect(helper.config, assert.success(function(client2, done2) {
16+
var boolTypeOID = 16;
17+
client1.setTypeParser(boolTypeOID, function(){
18+
return 'first client';
19+
});
20+
client2.setTypeParser(boolTypeOID, function(){
21+
return 'second client';
22+
});
23+
24+
client1.setTypeParser(boolTypeOID, 'binary', function(){
25+
return 'first client binary';
26+
});
27+
client2.setTypeParser(boolTypeOID, 'binary', function(){
28+
return 'second client binary';
29+
});
30+
31+
testTypeParser(client1, 'first client', done1);
32+
testTypeParser(client2, 'second client', done2);
33+
}));
34+
}));

0 commit comments

Comments
 (0)