Merge pull request #427 from brianc/parse-big-int
Add ability to opt-in to int8 parsing
This commit is contained in:
commit
dcd90673ac
@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
var defaults = module.exports = {
|
||||
// database host defaults to localhost
|
||||
host: 'localhost',
|
||||
|
||||
@ -38,3 +38,8 @@ module.exports = {
|
||||
|
||||
client_encoding: ""
|
||||
};
|
||||
|
||||
//parse int8 so you can get your count values as actual numbers
|
||||
module.exports.__defineSetter__("parseInt8", function(val) {
|
||||
require('./types').setTypeParser(20, 'text', val ? parseInt : function(val) { return val; });
|
||||
});
|
||||
|
18
test/integration/client/parse-int-8-tests.js
Normal file
18
test/integration/client/parse-int-8-tests.js
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
var helper = require(__dirname + '/../test-helper');
|
||||
var pg = helper.pg;
|
||||
test('ability to turn on and off parser', function() {
|
||||
if(helper.args.binary) return false;
|
||||
pg.connect(helper.config, assert.success(function(client, done) {
|
||||
pg.defaults.parseInt8 = true;
|
||||
client.query('CREATE TEMP TABLE asdf(id SERIAL PRIMARY KEY)');
|
||||
client.query('SELECT COUNT(*) as "count" FROM asdf', assert.success(function(res) {
|
||||
pg.defaults.parseInt8 = false;
|
||||
client.query('SELECT COUNT(*) as "count" FROM asdf', assert.success(function(res) {
|
||||
done();
|
||||
assert.strictEqual("0", res.rows[0].count);
|
||||
pg.end();
|
||||
}));
|
||||
}));
|
||||
}));
|
||||
});
|
Loading…
Reference in New Issue
Block a user