Comparing version 1.13.0 to 2.0.0
@@ -90,2 +90,15 @@ var array = require('postgres-array') | ||
var parseIntervalArray = function(value) { | ||
if (!value) { return null; } | ||
var p = arrayParser.create(value, function(entry) { | ||
if (entry !== null) { | ||
entry = parseInterval(entry); | ||
} | ||
return entry; | ||
}); | ||
return p.parse(); | ||
}; | ||
var parseByteAArray = function(value) { | ||
@@ -108,9 +121,5 @@ if (!value) { return null; } | ||
var parseJsonArray = function(value) { | ||
var arr = parseStringArray(value); | ||
if (!value) { return null; } | ||
if (!arr) { | ||
return arr; | ||
} | ||
return arr.map(function(el) { return JSON.parse(el); }); | ||
return array.parse(value, allowNull(JSON.parse)); | ||
}; | ||
@@ -193,2 +202,3 @@ | ||
register(1186, parseInterval); | ||
register(1187, parseIntervalArray); | ||
register(17, parseByteA); | ||
@@ -195,0 +205,0 @@ register(114, JSON.parse.bind(JSON)); // json |
{ | ||
"name": "pg-types", | ||
"version": "1.13.0", | ||
"version": "2.0.0", | ||
"description": "Query result type converters for node-postgres", | ||
@@ -31,7 +31,10 @@ "main": "index.js", | ||
"pg-int8": "1.0.1", | ||
"postgres-array": "~1.0.0", | ||
"postgres-array": "~2.0.0", | ||
"postgres-bytea": "~1.0.0", | ||
"postgres-date": "~1.0.0", | ||
"postgres-interval": "^1.1.0" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
} | ||
} |
@@ -335,2 +335,25 @@ 'use strict' | ||
exports['array/json'] = { | ||
format: 'text', | ||
id: 199, | ||
tests: [ | ||
[ | ||
'{{1,2},{[3],"[4,5]"},{null,NULL}}', | ||
function (t, value) { | ||
t.deepEqual(value, [ | ||
[1, 2], | ||
[[3], [4, 5]], | ||
[null, null], | ||
]) | ||
} | ||
] | ||
] | ||
} | ||
exports['array/jsonb'] = { | ||
format: 'text', | ||
id: 3807, | ||
tests: exports['array/json'].tests | ||
} | ||
exports['array/point'] = { | ||
@@ -395,2 +418,15 @@ format: 'text', | ||
exports['array/interval'] = { | ||
format: 'text', | ||
id: 1187, | ||
tests: [ | ||
['{01:02:03,1 day -00:00:03}', function (t, value) { | ||
var expecteds = [{hours: 1, minutes: 2, seconds: 3}, | ||
{days: 1, seconds: -3}] | ||
t.equal(value.length, 2) | ||
t.deepEqual(value, expecteds); | ||
}] | ||
] | ||
} | ||
exports['array/inet'] = { | ||
@@ -397,0 +433,0 @@ format: 'text', |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30180
1004
1
+ Addedpostgres-array@2.0.0(transitive)
- Removedpostgres-array@1.0.3(transitive)
Updatedpostgres-array@~2.0.0