parsing floats

This commit is contained in:
brianc 2010-10-27 00:15:58 -05:00
parent 368724d4f4
commit 86d5296fb0
3 changed files with 23 additions and 5 deletions

View File

@ -207,6 +207,9 @@ the database first and then re-create the data as follows:
- Typed result set support in client
- simple queries
- bound commands
- edge cases
- [numeric 'NaN' result](http://www.postgresql.org/docs/8.4/static/datatype-numeric.html)
- float Infinity, -Infinity
- Error handling
- disconnection, removal of listeners on errors
- passing errors to callbacks?

View File

@ -175,10 +175,10 @@ Client.dataTypeParser = {
20: parseInt,
21: parseInt,
23: parseInt,
26: parseInt
// 1700: floatParser,
// 700: floatParser,
// 701: floatParser,
26: parseInt,
1700: parseFloat,
700: parseFloat,
701: parseFloat
// 1083: timeParser,
// 1266: timeParser,
// 1114: dateParser,

View File

@ -18,6 +18,9 @@ test('typed results', function() {
testParses('smallInt / int2', 2, 4);
testParses('bigint / int8', 3, 1234567890);
testParses('oid', 4, 1234);
testParses('numeric', 5, 123.456);
testParses('real / float4', 6, 123.4567);
testParses('double', 7, 1234.5678);
});
con.emit('rowDescription', {
@ -37,6 +40,15 @@ test('typed results', function() {
},{
name: 'oid',
dataTypeID: 26
},{
name: 'numeric',
dataTypeID: 1700
},{
name: 'real, float4',
dataTypeID: 700
},{
name: 'double precision, float8',
dataTypeID: 701
}]
});
@ -45,7 +57,10 @@ test('typed results', function() {
'1394', //integer
'4', //smallint
'1234567890', //bigint (yes, i know, this isn't 8 bytes)
'1234' //oid
'1234', //oid
'123.456', //numeric
'123.4567', //real
'1234.5678' //double
]}));
});