New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

larvitdb

Package Overview
Dependencies
Maintainers
1
Versions
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

larvitdb - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

12

larvitdb.js

@@ -143,10 +143,8 @@ 'use strict';

// Convert datetimes to UTC
// Convert datetimes to UTC string
if (Array.isArray(dbFields)) {
for (let i = 0; dbFields[i] !== undefined; i ++) {
if (typeof dbFields[i] === Date) {
const dbField = dbFields[i];
dbField = dbField.toISOString();
dbField[10] = ' '; // Replace T with a space
dbField = dbField.substring(0, dbField.length - 1); // Cut the last Z off
for (let i = 0; i < dbFields.length; i ++) {
if (dbFields[i] instanceof Date) {
let dbField = dbFields[i].toISOString();
dbFields[i] = (dbField.substring(0, 10) + ' ' + dbField.slice(11)).substring(0, 19); // Replace T with ' ' and cut the last Z off
}

@@ -153,0 +151,0 @@ }

{
"name": "larvitdb",
"version": "2.1.1",
"version": "2.1.2",
"description": "DB wrapper module for node.js",

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

{
"extends": [
"config:base"
]
],
"automerge": true,
"major": {
"automerge": false
}
}

@@ -17,5 +17,10 @@ 'use strict';

if (err) throw err;
if (rows.length) throw new Error('Database is not empty. To make a test, you must supply an empty database!');
if (rows.length) {
// Remove tables
const dropTableQuery = 'DROP TABLE ' + rows.map(x => x.Tables_in_test).join(',');
done();
db.query(dropTableQuery, done);
} else {
done();
}
});

@@ -318,20 +323,36 @@ }

it('Time zone dependent data', function (done) {
const tasks = [];
const tasks = [],
dates = [];
// Create table
tasks.push(function (cb) {
const sql = 'CREATE TABLE tzstuff (id int(11), tzstamp timestamp, tzdatetime datetime);';
const sql = 'CREATE TABLE tzstuff (id int(11), text varchar(191), tzstamp timestamp, tzdatetime DATETIME);';
db.query(sql, cb);
});
// Set datetime as javascript Date object
// Set datetime as javascript Date object UTC
tasks.push(function (cb) {
const dateObj = new Date('2018-03-04T17:38:20Z');
db.query('INSERT INTO tzstuff VALUES(?,?,?);', [1, dateObj, dateObj], cb);
dates.push(new Date('2018-05-04T17:00:00Z'));
db.query('INSERT INTO tzstuff VALUES(?,?,?,?);', [1, '', dates[dates.length - 1], dates[dates.length - 1]], cb);
});
// Set date as javascript Date object
tasks.push(function (cb) {
dates.push(new Date('2018-05-04 17:00:00'));
db.query('INSERT INTO tzstuff VALUES(?,?,?,?);', [2, null, dates[dates.length - 1], dates[dates.length - 1]], cb);
});
// Set date as string
tasks.push(function (cb) {
dates.push('2018-05-04 17:00:00');
db.query('INSERT INTO tzstuff VALUES(?,?,?,?);', [3, undefined, dates[dates.length - 1], dates[dates.length - 1]], cb);
});
// Check the values
tasks.push(function (cb) {
db.query('SELECT * FROM tzstuff ORDER BY id', function (err, rows) {
let foundRows = 0;

@@ -341,12 +362,15 @@ if (err) throw err;

for (let i = 0; rows[i] !== undefined; i ++) {
const row = rows[i];
const row = rows[i],
date = dates[i] instanceof Date ? dates[i].toISOString().replace('T', ' ').replace('Z', '').substring(0, 19) : dates[i];
if (row.id === 1) {
foundRows ++;
assert.strictEqual(row.tzstamp.toISOString(), '2018-03-04T17:38:20.000Z');
assert.strictEqual(row.tzdatetime.toISOString(), '2018-03-04T17:38:20.000Z');
if (row.tzstamp instanceof Date) {
err = new Error('dateStrings is not set to true in db config');
throw err;
}
assert.equal(row.tzstamp, date);
assert.equal(row.tzdatetime, date);
}
assert.strictEqual(foundRows, 1);
assert.strictEqual(rows.length, dates.length);

@@ -353,0 +377,0 @@ cb();

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