Skip to content

Commit a5ee365

Browse files
committed
remove parseFloat
1 parent e93a4a5 commit a5ee365

File tree

3 files changed

+8
-37
lines changed

3 files changed

+8
-37
lines changed

lib/types/textParsers.js

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,8 @@ var parseIntegerArray = function(val) {
7878
};
7979

8080
var parseFloatArray = function(val) {
81-
deprecate('parsing and returning floats from PostgreSQL server is deprecated',
82-
'JavaScript has a hard time with floats and there is precision loss which can cause',
83-
'unexpected, hard to trace, potentially bad bugs in your program',
84-
'for more information see the following:',
85-
'https://github.com/brianc/node-postgres/pull/271',
86-
'in node-postgres v1.0.0 all floats & decimals will be returned as strings',
87-
'feel free to get in touch via a github issue if you have any questions');
8881
if(!val) { return null; }
89-
var p = arrayParser.create(val, function(entry){
90-
if(entry !== null) {
91-
entry = parseFloat(entry, 10);
92-
}
82+
var p = arrayParser.create(val, function(entry) {
9383
return entry;
9484
});
9585

@@ -171,36 +161,18 @@ var parseInteger = function(val) {
171161
return parseInt(val, 10);
172162
};
173163

174-
var parseFloatAndWarn = function(val) {
175-
deprecate('parsing and returning floats from PostgreSQL server is deprecated',
176-
'JavaScript has a hard time with floats and there is precision loss which can cause',
177-
'unexpected, hard to trace, potentially bad bugs in your program',
178-
'for more information see the following:',
179-
'https://github.com/brianc/node-postgres/pull/271',
180-
'in node-postgres v1.0.0 all floats & decimals will be returned as strings');
181-
return parseFloat(val);
182-
};
183-
184164
var init = function(register) {
185165
register(20, parseInteger);
186166
register(21, parseInteger);
187167
register(23, parseInteger);
188168
register(26, parseInteger);
189-
//TODO remove for v1.0
190-
register(1700, parseFloatAndWarn);
191-
//TODO remove for v1.0
192-
register(700, parseFloatAndWarn);
193-
//TODO remove for v1.0
194-
register(701, parseFloatAndWarn);
195169
register(16, parseBool);
196170
register(1082, parseDate); // date
197171
register(1114, parseDate); // timestamp without timezone
198172
register(1184, parseDate); // timestamp
199173
register(1005, parseIntegerArray); // _int2
200174
register(1007, parseIntegerArray); // _int4
201175
register(1016, parseIntegerArray); // _int8
202-
register(1021, parseFloatArray); // _float4
203-
register(1022, parseFloatArray); // _float8
204176
register(1231, parseIntegerArray); // _numeric
205177
register(1014, parseStringArray); //char
206178
register(1015, parseStringArray); //varchar

test/integration/client/type-coercion-tests.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,14 @@ var types = [{
5757
name: 'bool',
5858
values: [true, false, null]
5959
},{
60-
//TODO get some actual huge numbers here
6160
name: 'numeric',
62-
values: [-12.34, 0, 12.34, null]
61+
values: ['-12.34', '0', '12.34', null]
6362
},{
6463
name: 'real',
65-
values: [101.1, 0, -101.3, null]
64+
values: ['101.1', '0', '-101.3', null]
6665
},{
6766
name: 'double precision',
68-
values: [-1.2, 0, 1.2, null]
67+
values: ['-1.2', '0', '1.2', null]
6968
},{
7069
name: 'timestamptz',
7170
values: [null]
@@ -83,7 +82,7 @@ var types = [{
8382
// ignore some tests in binary mode
8483
if (helper.config.binary) {
8584
types = types.filter(function(type) {
86-
return !(type.name in {'real':1, 'timetz':1, 'time':1});
85+
return !(type.name in {'real':1, 'timetz':1, 'time':1, 'numeric': 1, 'double precision': 1});
8786
});
8887
}
8988

test/unit/client/typed-query-results-tests.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,19 @@ test('typed results', function() {
4343
format: 'text',
4444
dataTypeID: 1700,
4545
actual: '12.34',
46-
expected: 12.34
46+
expected: '12.34'
4747
},{
4848
name: 'real/float4',
4949
dataTypeID: 700,
5050
format: 'text',
5151
actual: '123.456',
52-
expected: 123.456
52+
expected: '123.456'
5353
},{
5454
name: 'double precision / float8',
5555
format: 'text',
5656
dataTypeID: 701,
5757
actual: '1.2',
58-
expected: 1.2
58+
expected: '1.2'
5959
},{
6060
name: 'boolean true',
6161
format: 'text',

0 commit comments

Comments
 (0)