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

sql-ddl-sync

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sql-ddl-sync - npm Package Compare versions

Comparing version 0.3.18 to 0.4.0

3

Changelog.md

@@ -0,1 +1,4 @@

### v0.4.0 - 2022-03-16
- Add `renameCollection` function
### v0.3.18 - 2022-01-11

@@ -2,0 +5,0 @@ - Add support for `defaultExpression` ie. `uuid()` for [MySQL 8.0.13+](https://dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html)

@@ -150,2 +150,9 @@ var SQL = require("../SQL");

exports.renameCollection = function(driver, oldCollectionName, newCollectionName, cb) {
return driver.execQuery(SQL.ALTER_TABLE_RENAME({
name : oldCollectionName,
newName: newCollectionName
}, driver), cb);
}
exports.dropCollection = function (driver, name, cb) {

@@ -152,0 +159,0 @@ return driver.execQuery(SQL.DROP_TABLE({

14

lib/Dialects/postgresql.js

@@ -127,2 +127,9 @@ var _ = require("lodash");

exports.renameCollection = function(driver, oldCollectionName, newCollectionName, cb) {
return driver.execQuery(SQL.ALTER_TABLE_RENAME({
name : oldCollectionName,
newName: newCollectionName
}, driver), cb);
}
exports.dropCollection = function (driver, name, cb) {

@@ -155,9 +162,2 @@ return driver.execQuery(SQL.DROP_TABLE({

//exports.renameTable = function(driver, oldCollectionName, newCollectionName, cb) {
// return driver.execQuery(SQL.RENAME_TABLE({
// oldCollectionName : oldCollectionName,
// newCollectionName : newCollectionName
// }, driver), cb);
//}
exports.addCollectionColumn = function (driver, name, column, afterColumn, cb) {

@@ -164,0 +164,0 @@ var sql = "ALTER TABLE ?? ADD " + column + ";";

@@ -110,2 +110,9 @@ var Queue = require("../Queue").Queue;

exports.renameCollection = function(driver, oldCollectionName, newCollectionName, cb) {
return driver.execQuery(SQL.ALTER_TABLE_RENAME({
name : oldCollectionName,
newName: newCollectionName
}, driver), cb);
}
exports.dropCollection = function (driver, name, cb) {

@@ -112,0 +119,0 @@ return driver.execQuery(SQL.DROP_TABLE({

@@ -21,2 +21,6 @@ exports.CREATE_TABLE = function (options, driver) {

exports.ALTER_TABLE_RENAME = function(options, driver) {
return driver.generateQuery("ALTER TABLE ?? RENAME TO ??", [options.name, options.newName]);
}
exports.ALTER_TABLE_ADD_COLUMN = function (options, driver) {

@@ -71,5 +75,1 @@ var sql = "ALTER TABLE " + driver.query.escapeId(options.name) +

};
//exports.RENAME_TABLE = function(options, driver) {
// var sql = "ALTER TABLE " + options.oldCollectionName + " RENAME TO " + options.newCollectionName + " ;";
//}

@@ -13,3 +13,3 @@ {

],
"version": "0.3.18",
"version": "0.4.0",
"license": "MIT",

@@ -29,8 +29,8 @@ "repository": "http://github.com/dresende/node-sql-ddl-sync.git",

"devDependencies": {
"mocha": "5.2.0",
"mocha": "9.2.2",
"should": "~13.2.3",
"sinon": "~12.0.1",
"commander": "2.15.1",
"orm": "~5.0.9"
"sinon": "~13.0.1",
"commander": "9.0.0",
"orm": "~6.2.0"
}
}

@@ -5,2 +5,16 @@ exports.dialect = null;

exports.fakeDriver = {
generateQuery: function (sql, params) {
var count = 0;
return sql.replace(/\?+/g, function (match) {
var val = params[count++];
if (match == '??') {
return exports.fakeDriver.query.escapeId(val);
} else if (match == '?') {
return exports.fakeDriver.query.escapeVal(val);
} else {
return "unexpected match: " + match;
}
});
},
query: {

@@ -7,0 +21,0 @@ escapeId : function (id) {

var should = require("should");
var sinon = require("sinon");
var common = require("../common");

@@ -6,93 +7,113 @@ var Dialect = require("../../lib/Dialects/mysql");

describe("MySQL.getType", function () {
it("should detect text", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "text" }, driver).value.should.equal("VARCHAR(255)");
Dialect.getType(null, { mapsTo: 'abc', type: "text", size: 150 }, driver).value.should.equal("VARCHAR(150)");
Dialect.getType(null, { mapsTo: 'abc', type: "text", size: 1000 }, driver).value.should.equal("VARCHAR(1000)");
describe("MySQL", function () {
describe(".getType", function () {
it("should detect text", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "text" }, driver).value.should.equal("VARCHAR(255)");
Dialect.getType(null, { mapsTo: 'abc', type: "text", size: 150 }, driver).value.should.equal("VARCHAR(150)");
Dialect.getType(null, { mapsTo: 'abc', type: "text", size: 1000 }, driver).value.should.equal("VARCHAR(1000)");
return done();
});
return done();
});
it("should detect numbers", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "integer" }, driver).value.should.equal("INTEGER");
Dialect.getType(null, { mapsTo: 'abc', type: "integer", size: 4 }, driver).value.should.equal("INTEGER");
Dialect.getType(null, { mapsTo: 'abc', type: "integer", size: 2 }, driver).value.should.equal("SMALLINT");
Dialect.getType(null, { mapsTo: 'abc', type: "integer", size: 8 }, driver).value.should.equal("BIGINT");
Dialect.getType(null, { mapsTo: 'abc', type: "number", rational: false }, driver).value.should.equal("INTEGER");
it("should detect numbers", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "integer" }, driver).value.should.equal("INTEGER");
Dialect.getType(null, { mapsTo: 'abc', type: "integer", size: 4 }, driver).value.should.equal("INTEGER");
Dialect.getType(null, { mapsTo: 'abc', type: "integer", size: 2 }, driver).value.should.equal("SMALLINT");
Dialect.getType(null, { mapsTo: 'abc', type: "integer", size: 8 }, driver).value.should.equal("BIGINT");
Dialect.getType(null, { mapsTo: 'abc', type: "number", rational: false }, driver).value.should.equal("INTEGER");
return done();
});
return done();
});
it("should detect rational numbers", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "number"}, driver).value.should.equal("FLOAT");
Dialect.getType(null, { mapsTo: 'abc', type: "number", size: 4 }, driver).value.should.equal("FLOAT");
Dialect.getType(null, { mapsTo: 'abc', type: "number", size: 8 }, driver).value.should.equal("DOUBLE");
it("should detect rational numbers", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "number"}, driver).value.should.equal("FLOAT");
Dialect.getType(null, { mapsTo: 'abc', type: "number", size: 4 }, driver).value.should.equal("FLOAT");
Dialect.getType(null, { mapsTo: 'abc', type: "number", size: 8 }, driver).value.should.equal("DOUBLE");
return done();
});
return done();
});
it("should detect booleans", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "boolean" }, driver).value.should.equal("TINYINT(1)");
it("should detect booleans", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "boolean" }, driver).value.should.equal("TINYINT(1)");
return done();
});
return done();
});
it("should detect dates", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "date" }, driver).value.should.equal("DATE");
it("should detect dates", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "date" }, driver).value.should.equal("DATE");
return done();
});
return done();
});
it("should detect dates with times", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "date", time: true }, driver).value.should.equal("DATETIME");
it("should detect dates with times", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "date", time: true }, driver).value.should.equal("DATETIME");
return done();
});
return done();
});
it("should detect binary", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "binary" }, driver).value.should.equal("BLOB");
it("should detect binary", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "binary" }, driver).value.should.equal("BLOB");
return done();
});
return done();
});
it("should detect big binary", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "binary", big: true }, driver).value.should.equal("LONGBLOB");
it("should detect big binary", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "binary", big: true }, driver).value.should.equal("LONGBLOB");
return done();
});
return done();
});
it("should detect custom types", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "json" }, driver).value.should.equal("JSON");
it("should detect custom types", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "json" }, driver).value.should.equal("JSON");
return done();
});
return done();
});
it("should detect required items", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "boolean", required: true }, driver).value.should.match(/NOT NULL/);
it("should detect required items", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "boolean", required: true }, driver).value.should.match(/NOT NULL/);
return done();
});
return done();
});
it("should detect default values", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "number", defaultValue: 3 }, driver).value.should.match(/DEFAULT \^\^3\^\^/);
it("should detect default values", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "number", defaultValue: 3 }, driver).value.should.match(/DEFAULT \^\^3\^\^/);
return done();
});
return done();
});
it("should detect serial", function (done) {
var column = Dialect.getType(null, { mapsTo: 'abc', type: "serial" }).value;
it("should detect serial", function (done) {
var column = Dialect.getType(null, { mapsTo: 'abc', type: "serial" }).value;
column.should.match(/INT/);
column.should.match(/NOT NULL/);
column.should.match(/AUTO_INCREMENT/);
column.should.match(/INT/);
column.should.match(/NOT NULL/);
column.should.match(/AUTO_INCREMENT/);
return done();
return done();
});
it("should detect default expressions", function () {
should.equal(
Dialect.getType(null, { mapsTo: 'abc', type: 'text', defaultExpression: 'uuid()' }, driver).value,
'VARCHAR(255) DEFAULT (uuid())'
);
});
});
it("should detect default expressions", function () {
should.equal(
Dialect.getType(null, { mapsTo: 'abc', type: 'text', defaultExpression: 'uuid()' }, driver).value,
'VARCHAR(255) DEFAULT (uuid())'
);
describe(".renameCollection", function () {
var driver;
beforeEach(function () {
driver = {
generateQuery: common.fakeDriver.generateQuery,
execQuery: sinon.stub(),
};
});
it("should run correct SQL", function () {
Dialect.renameCollection(driver, 'old_name', 'new_name', 'callback'),
sinon.assert.calledOnce(driver.execQuery);
sinon.assert.calledWith(driver.execQuery, 'ALTER TABLE $$old_name$$ RENAME TO $$new_name$$', 'callback');
});
});
});

@@ -7,71 +7,95 @@ var should = require("should");

describe("PostgreSQL.getCollectionProperties", function () {
it("should detect UUID", function () {
should.deepEqual(
Dialect.getColumnProperties({ data_type: 'uuid' }),
{ type: 'uuid' }
);
describe("PostgreSQL", function () {
afterEach(function () {
sinon.restore();
});
});
describe("PostgreSQL.getType", function () {
it("should detect text", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "text" }, driver).value.should.equal("TEXT");
Dialect.getType(null, { mapsTo: 'abc', type: "text", size: 150 }, driver).value.should.equal("TEXT");
Dialect.getType(null, { mapsTo: 'abc', type: "text", size: 1000 }, driver).value.should.equal("TEXT");
describe(".getCollectionProperties", function () {
it("should detect UUID", function () {
should.deepEqual(
Dialect.getColumnProperties({ data_type: 'uuid' }),
{ type: 'uuid' }
);
});
});
it("should detect numbers", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "integer" }, driver).value.should.equal("INTEGER");
Dialect.getType(null, { mapsTo: 'abc', type: "integer", size: 4 }, driver).value.should.equal("INTEGER");
Dialect.getType(null, { mapsTo: 'abc', type: "integer", size: 2 }, driver).value.should.equal("SMALLINT");
Dialect.getType(null, { mapsTo: 'abc', type: "integer", size: 8 }, driver).value.should.equal("BIGINT");
Dialect.getType(null, { mapsTo: 'abc', type: "number", rational: false }, driver).value.should.equal("INTEGER");
});
describe(".getType", function () {
it("should detect text", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "text" }, driver).value.should.equal("TEXT");
Dialect.getType(null, { mapsTo: 'abc', type: "text", size: 150 }, driver).value.should.equal("TEXT");
Dialect.getType(null, { mapsTo: 'abc', type: "text", size: 1000 }, driver).value.should.equal("TEXT");
});
it("should detect rational numbers", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "number"}, driver).value.should.equal("REAL");
Dialect.getType(null, { mapsTo: 'abc', type: "number", size: 4 }, driver).value.should.equal("REAL");
Dialect.getType(null, { mapsTo: 'abc', type: "number", size: 8 }, driver).value.should.equal("DOUBLE PRECISION");
});
it("should detect numbers", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "integer" }, driver).value.should.equal("INTEGER");
Dialect.getType(null, { mapsTo: 'abc', type: "integer", size: 4 }, driver).value.should.equal("INTEGER");
Dialect.getType(null, { mapsTo: 'abc', type: "integer", size: 2 }, driver).value.should.equal("SMALLINT");
Dialect.getType(null, { mapsTo: 'abc', type: "integer", size: 8 }, driver).value.should.equal("BIGINT");
Dialect.getType(null, { mapsTo: 'abc', type: "number", rational: false }, driver).value.should.equal("INTEGER");
});
it("should detect booleans", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "boolean" }, driver).value.should.equal("BOOLEAN");
});
it("should detect rational numbers", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "number"}, driver).value.should.equal("REAL");
Dialect.getType(null, { mapsTo: 'abc', type: "number", size: 4 }, driver).value.should.equal("REAL");
Dialect.getType(null, { mapsTo: 'abc', type: "number", size: 8 }, driver).value.should.equal("DOUBLE PRECISION");
});
it("should detect dates", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "date" }, driver).value.should.equal("DATE");
});
it("should detect booleans", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "boolean" }, driver).value.should.equal("BOOLEAN");
});
it("should detect dates with times", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "date", time: true }, driver).value.should.equal("TIMESTAMP WITHOUT TIME ZONE");
});
it("should detect dates", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "date" }, driver).value.should.equal("DATE");
});
it("should detect binary", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "binary" }, driver).value.should.equal("BYTEA");
});
it("should detect dates with times", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "date", time: true }, driver).value.should.equal("TIMESTAMP WITHOUT TIME ZONE");
});
it("should detect uuid", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "uuid" }, driver).value.should.equal("UUID");
});
it("should detect binary", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "binary" }, driver).value.should.equal("BYTEA");
});
it("should detect custom types", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "json" }, driver).value.should.equal("JSON");
});
it("should detect uuid", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "uuid" }, driver).value.should.equal("UUID");
});
it("should detect required items", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "boolean", required: true }, driver).value.should.match(/NOT NULL/);
});
it("should detect custom types", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "json" }, driver).value.should.equal("JSON");
});
it("should detect default values", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "number", defaultValue: 3 }, driver).value.should.match(/DEFAULT \^\^3\^\^/);
Dialect.getType(null, { mapsTo: 'abc', type: 'date', defaultValue: Date.now }, driver).value.should.equal('DATE DEFAULT now()');
it("should detect required items", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "boolean", required: true }, driver).value.should.match(/NOT NULL/);
});
it("should detect default values", function () {
Dialect.getType(null, { mapsTo: 'abc', type: "number", defaultValue: 3 }, driver).value.should.match(/DEFAULT \^\^3\^\^/);
Dialect.getType(null, { mapsTo: 'abc', type: 'date', defaultValue: Date.now }, driver).value.should.equal('DATE DEFAULT now()');
});
it("should detect default expressions", function () {
should.equal(
Dialect.getType(null, { mapsTo: 'abc', type: 'uuid', defaultExpression: 'uuid_generate_v4()' }, driver).value,
'UUID DEFAULT uuid_generate_v4()'
);
});
});
it("should detect default expressions", function () {
should.equal(
Dialect.getType(null, { mapsTo: 'abc', type: 'uuid', defaultExpression: 'uuid_generate_v4()' }, driver).value,
'UUID DEFAULT uuid_generate_v4()'
);
describe(".renameCollection", function () {
var driver;
beforeEach(function () {
driver = {
generateQuery: common.fakeDriver.generateQuery,
execQuery: sinon.stub(),
};
});
it("should run correct SQL", function () {
Dialect.renameCollection(driver, 'old_name', 'new_name', 'callback'),
sinon.assert.calledOnce(driver.execQuery);
sinon.assert.calledWith(driver.execQuery, 'ALTER TABLE $$old_name$$ RENAME TO $$new_name$$', 'callback');
});
});
});

@@ -40,2 +40,10 @@ var should = require("should");

describe("SQL.ALTER_TABLE_RENAME", function () {
it("should return a ALTER TABLE RENAME", function () {
SQL.ALTER_TABLE_RENAME({
name : "fake_table",
newName : "fake_table2"
}, driver).should.equal("ALTER TABLE $$fake_table$$ RENAME TO $$fake_table2$$");
});
});

@@ -42,0 +50,0 @@ describe("SQL.ALTER_TABLE_ADD_COLUMN", function () {

var should = require("should");
var sinon = require("sinon");
var common = require("../common");

@@ -6,74 +7,94 @@ var Dialect = require("../../lib/Dialects/sqlite");

describe("SQLite.getType", function () {
it("should detect text", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "text" }, driver).value.should.equal("TEXT");
Dialect.getType(null, { mapsTo: 'abc', type: "text", size: 150 }, driver).value.should.equal("TEXT");
describe("SQLite", function () {
describe(".getType", function () {
it("should detect text", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "text" }, driver).value.should.equal("TEXT");
Dialect.getType(null, { mapsTo: 'abc', type: "text", size: 150 }, driver).value.should.equal("TEXT");
return done();
});
return done();
});
it("should detect numbers", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "integer" }, driver).value.should.equal("INTEGER");
Dialect.getType(null, { mapsTo: 'abc', type: "integer", size: 4 }, driver).value.should.equal("INTEGER");
Dialect.getType(null, { mapsTo: 'abc', type: "integer", size: 2 }, driver).value.should.equal("INTEGER");
Dialect.getType(null, { mapsTo: 'abc', type: "integer", size: 8 }, driver).value.should.equal("INTEGER");
Dialect.getType(null, { mapsTo: 'abc', type: "number", rational: false }, driver).value.should.equal("INTEGER");
it("should detect numbers", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "integer" }, driver).value.should.equal("INTEGER");
Dialect.getType(null, { mapsTo: 'abc', type: "integer", size: 4 }, driver).value.should.equal("INTEGER");
Dialect.getType(null, { mapsTo: 'abc', type: "integer", size: 2 }, driver).value.should.equal("INTEGER");
Dialect.getType(null, { mapsTo: 'abc', type: "integer", size: 8 }, driver).value.should.equal("INTEGER");
Dialect.getType(null, { mapsTo: 'abc', type: "number", rational: false }, driver).value.should.equal("INTEGER");
return done();
});
return done();
});
it("should detect rational numbers", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "number"}, driver).value.should.equal("REAL");
Dialect.getType(null, { mapsTo: 'abc', type: "number", size: 4 }, driver).value.should.equal("REAL");
Dialect.getType(null, { mapsTo: 'abc', type: "number", size: 8 }, driver).value.should.equal("REAL");
it("should detect rational numbers", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "number"}, driver).value.should.equal("REAL");
Dialect.getType(null, { mapsTo: 'abc', type: "number", size: 4 }, driver).value.should.equal("REAL");
Dialect.getType(null, { mapsTo: 'abc', type: "number", size: 8 }, driver).value.should.equal("REAL");
return done();
});
return done();
});
it("should detect booleans", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "boolean" }, driver).value.should.equal("INTEGER UNSIGNED");
it("should detect booleans", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "boolean" }, driver).value.should.equal("INTEGER UNSIGNED");
return done();
});
return done();
});
it("should detect dates", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "date" }, driver).value.should.equal("DATETIME");
Dialect.getType(null, { mapsTo: 'abc', type: "date", time: true }, driver).value.should.equal("DATETIME");
it("should detect dates", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "date" }, driver).value.should.equal("DATETIME");
Dialect.getType(null, { mapsTo: 'abc', type: "date", time: true }, driver).value.should.equal("DATETIME");
return done();
});
return done();
});
it("should detect binary", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "binary" }, driver).value.should.equal("BLOB");
Dialect.getType(null, { mapsTo: 'abc', type: "binary", big: true }, driver).value.should.equal("BLOB");
it("should detect binary", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "binary" }, driver).value.should.equal("BLOB");
Dialect.getType(null, { mapsTo: 'abc', type: "binary", big: true }, driver).value.should.equal("BLOB");
return done();
});
return done();
});
it("should detect custom types", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "json" }, driver).value.should.equal("JSON");
it("should detect custom types", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "json" }, driver).value.should.equal("JSON");
return done();
});
return done();
});
it("should detect required items", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "boolean", required: true }, driver).value.should.match(/NOT NULL/);
it("should detect required items", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "boolean", required: true }, driver).value.should.match(/NOT NULL/);
return done();
});
return done();
});
it("should detect default values", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "number", defaultValue: 3 }, driver).value.should.match(/DEFAULT \^\^3\^\^/);
it("should detect default values", function (done) {
Dialect.getType(null, { mapsTo: 'abc', type: "number", defaultValue: 3 }, driver).value.should.match(/DEFAULT \^\^3\^\^/);
return done();
return done();
});
it("should detect serial", function (done) {
var column = Dialect.getType(null, { mapsTo: 'abc', type: "serial" }).value;
column.should.match(/INT/);
column.should.match(/AUTOINCREMENT/);
return done();
});
});
it("should detect serial", function (done) {
var column = Dialect.getType(null, { mapsTo: 'abc', type: "serial" }).value;
describe(".renameCollection", function () {
var driver;
column.should.match(/INT/);
column.should.match(/AUTOINCREMENT/);
beforeEach(function () {
driver = {
generateQuery: common.fakeDriver.generateQuery,
execQuery: sinon.stub(),
};
});
return done();
it("should run correct SQL", function () {
Dialect.renameCollection(driver, 'old_name', 'new_name', 'callback'),
sinon.assert.calledOnce(driver.execQuery);
sinon.assert.calledWith(driver.execQuery, 'ALTER TABLE $$old_name$$ RENAME TO $$new_name$$', 'callback');
});
});
});
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