remove parseFloat
This commit is contained in:
parent
e93a4a5d66
commit
a5ee365116
@ -78,18 +78,8 @@ var parseIntegerArray = function(val) {
|
||||
};
|
||||
|
||||
var parseFloatArray = function(val) {
|
||||
deprecate('parsing and returning floats from PostgreSQL server is deprecated',
|
||||
'JavaScript has a hard time with floats and there is precision loss which can cause',
|
||||
'unexpected, hard to trace, potentially bad bugs in your program',
|
||||
'for more information see the following:',
|
||||
'https://github.com/brianc/node-postgres/pull/271',
|
||||
'in node-postgres v1.0.0 all floats & decimals will be returned as strings',
|
||||
'feel free to get in touch via a github issue if you have any questions');
|
||||
if(!val) { return null; }
|
||||
var p = arrayParser.create(val, function(entry) {
|
||||
if(entry !== null) {
|
||||
entry = parseFloat(entry, 10);
|
||||
}
|
||||
return entry;
|
||||
});
|
||||
|
||||
@ -171,27 +161,11 @@ var parseInteger = function(val) {
|
||||
return parseInt(val, 10);
|
||||
};
|
||||
|
||||
var parseFloatAndWarn = function(val) {
|
||||
deprecate('parsing and returning floats from PostgreSQL server is deprecated',
|
||||
'JavaScript has a hard time with floats and there is precision loss which can cause',
|
||||
'unexpected, hard to trace, potentially bad bugs in your program',
|
||||
'for more information see the following:',
|
||||
'https://github.com/brianc/node-postgres/pull/271',
|
||||
'in node-postgres v1.0.0 all floats & decimals will be returned as strings');
|
||||
return parseFloat(val);
|
||||
};
|
||||
|
||||
var init = function(register) {
|
||||
register(20, parseInteger);
|
||||
register(21, parseInteger);
|
||||
register(23, parseInteger);
|
||||
register(26, parseInteger);
|
||||
//TODO remove for v1.0
|
||||
register(1700, parseFloatAndWarn);
|
||||
//TODO remove for v1.0
|
||||
register(700, parseFloatAndWarn);
|
||||
//TODO remove for v1.0
|
||||
register(701, parseFloatAndWarn);
|
||||
register(16, parseBool);
|
||||
register(1082, parseDate); // date
|
||||
register(1114, parseDate); // timestamp without timezone
|
||||
@ -199,8 +173,6 @@ var init = function(register) {
|
||||
register(1005, parseIntegerArray); // _int2
|
||||
register(1007, parseIntegerArray); // _int4
|
||||
register(1016, parseIntegerArray); // _int8
|
||||
register(1021, parseFloatArray); // _float4
|
||||
register(1022, parseFloatArray); // _float8
|
||||
register(1231, parseIntegerArray); // _numeric
|
||||
register(1014, parseStringArray); //char
|
||||
register(1015, parseStringArray); //varchar
|
||||
|
@ -57,15 +57,14 @@ var types = [{
|
||||
name: 'bool',
|
||||
values: [true, false, null]
|
||||
},{
|
||||
//TODO get some actual huge numbers here
|
||||
name: 'numeric',
|
||||
values: [-12.34, 0, 12.34, null]
|
||||
values: ['-12.34', '0', '12.34', null]
|
||||
},{
|
||||
name: 'real',
|
||||
values: [101.1, 0, -101.3, null]
|
||||
values: ['101.1', '0', '-101.3', null]
|
||||
},{
|
||||
name: 'double precision',
|
||||
values: [-1.2, 0, 1.2, null]
|
||||
values: ['-1.2', '0', '1.2', null]
|
||||
},{
|
||||
name: 'timestamptz',
|
||||
values: [null]
|
||||
@ -83,7 +82,7 @@ var types = [{
|
||||
// ignore some tests in binary mode
|
||||
if (helper.config.binary) {
|
||||
types = types.filter(function(type) {
|
||||
return !(type.name in {'real':1, 'timetz':1, 'time':1});
|
||||
return !(type.name in {'real':1, 'timetz':1, 'time':1, 'numeric': 1, 'double precision': 1});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -43,19 +43,19 @@ test('typed results', function() {
|
||||
format: 'text',
|
||||
dataTypeID: 1700,
|
||||
actual: '12.34',
|
||||
expected: 12.34
|
||||
expected: '12.34'
|
||||
},{
|
||||
name: 'real/float4',
|
||||
dataTypeID: 700,
|
||||
format: 'text',
|
||||
actual: '123.456',
|
||||
expected: 123.456
|
||||
expected: '123.456'
|
||||
},{
|
||||
name: 'double precision / float8',
|
||||
format: 'text',
|
||||
dataTypeID: 701,
|
||||
actual: '1.2',
|
||||
expected: 1.2
|
||||
expected: '1.2'
|
||||
},{
|
||||
name: 'boolean true',
|
||||
format: 'text',
|
||||
|
Loading…
Reference in New Issue
Block a user