Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pg-types

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-types - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

13

lib/textParsers.js

@@ -125,3 +125,15 @@ var arrayParser = require(__dirname + "/arrayParser.js");

var parseDateArray = function(val) {
if (!val) { return null; }
var p = arrayParser.create(val, function(entry) {
if (entry !== null) {
entry = parseDate(entry);
}
return entry;
});
return p.parse();
};
var NUM = '([+-]?\\d+)';

@@ -231,2 +243,3 @@ var YEAR = NUM + '\\s+years?';

register(1009, parseStringArray);
register(1182, parseDateArray); // date array
register(1186, parseInterval);

@@ -233,0 +246,0 @@ register(17, parseByteA);

2

package.json
{
"name": "pg-types",
"version": "1.1.0",
"version": "1.2.0",
"description": "Query result type converters for node-postgres",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -84,3 +84,3 @@

expected: function(val) {
assert.UTCDate(val, 2011, 0, 24, 4, 5, 00, 680);
assert.UTCDate(val, 2011, 0, 24, 4, 5, 0, 680);
}

@@ -118,5 +118,5 @@ }, {

expected: function(val) {
var now = new Date(2010, 9, 31)
var now = new Date(2010, 9, 31);
assert.UTCDate(val, 2010, now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), 0, 0, 0);
assert.equal(val.getHours(), now.getHours())
assert.equal(val.getHours(), now.getHours());
}

@@ -129,3 +129,3 @@ },{

expected: function(val) {
assert.deepEqual(val, {'hours':1, 'minutes':2, 'seconds':3})
assert.deepEqual(val, {'hours':1, 'minutes':2, 'seconds':3});
}

@@ -138,3 +138,3 @@ },{

expected: function(val) {
assert.deepEqual(val, {'years':1, 'days':-32})
assert.deepEqual(val, {'years':1, 'days':-32});
}

@@ -147,3 +147,3 @@ },{

expected: function(val) {
assert.deepEqual(val, {'days':1, 'seconds':-3})
assert.deepEqual(val, {'days':1, 'seconds':-3});
}

@@ -245,2 +245,16 @@ },{

},{
name : 'array/date',
format : 'text',
dataTypeID: 1182,
actual: '{2014-01-01,2015-12-31}',
expected :function(val){
var now = new Date(2014, 0, 1);
var then = new Date(2015, 11, 31);
assert.equal(val.length, 2);
val.forEach(function(element, index) {
var match = index ? then : now;
assert.UTCDate(element, match.getUTCFullYear(), match.getUTCMonth(), match.getUTCDate(), match.getUTCHours(), 0, 0, 0);
});
}
},{
name: 'binary-string/varchar',

@@ -338,18 +352,18 @@ format: 'binary',

tests.forEach(function(test) {
test.format = test.format || 'text'
test.format = test.format || 'text';
it('correctly parses ' + test.name + ' (' + test.format + ')', function() {
var parser = pgTypes.getTypeParser(test.dataTypeID, test.format)
var result = parser(test.actual)
var parser = pgTypes.getTypeParser(test.dataTypeID, test.format);
var result = parser(test.actual);
if(typeof test.expected == 'function') {
return test.expected(result)
return test.expected(result);
}
assert.strictEqual(result, test.expected)
})
})
})
assert.strictEqual(result, test.expected);
});
});
});
describe('interface', function() {
it('exports text parsers by default', function() {
assert.strictEqual(pgTypes.getTypeParser(23), pgTypes.getTypeParser(23, 'text'))
})
})
assert.strictEqual(pgTypes.getTypeParser(23), pgTypes.getTypeParser(23, 'text'));
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc