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

json-schema-table

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-schema-table - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

12

index.js

@@ -248,2 +248,4 @@ var _ = require('lodash');

case 'text':
column = 'NVARCHAR(MAX)';
break;
case 'string':

@@ -323,2 +325,4 @@ column = 'NVARCHAR(' + (property.maxLength ? property.maxLength : 'MAX') + ')';

case 'text':
column = 'TEXT';
break;
case 'string':

@@ -467,7 +471,8 @@ if (property.maxLength) {

is.decimals === void 0) ||
(was.type === 'datetime' && is.type === 'date');
(was.type === 'datetime' && is.type === 'date') ||
(was.type === 'text' && (is.type === 'string' && is.maxLength === void 0));
}
function canAlterColumn(from, to) {
return from.type === to.type &&
return (from.type === to.type &&
(from.type === 'string' &&

@@ -478,3 +483,4 @@ from.maxLength < to.maxLength) ||

from.decimals <= to.decimals &&
to.maxLength - from.maxLength >= to.decimals - from.decimals);
to.maxLength - from.maxLength >= to.decimals - from.decimals)) ||
(from.type === 'string' && to.type === 'text');
}

@@ -481,0 +487,0 @@

{
"name": "json-schema-table",
"version": "0.0.2",
"version": "0.0.3",
"description": "Creates and maintains a SQL table structure",

@@ -5,0 +5,0 @@ "homepage": "",

@@ -18,2 +18,5 @@ {

},
"summary": {
"type": "string"
},
"description": {

@@ -20,0 +23,0 @@ "type": "text"

@@ -12,2 +12,3 @@ var jsonSchemaTable = require('..');

var modifiedClientSchema;
var modifiedPersonSchema;
var modifiedTaxSchema;

@@ -31,2 +32,5 @@

expect(columns[columnName].maxLength).to.equal(undefined);
} else if (property.type === 'string' && property.maxLength === void 0) {
expect(columns[columnName].type === 'text').to.equal(true);
expect(columns[columnName].maxLength).to.equal(undefined);
} else if (property.type === 'object' || property.type === void 0) {

@@ -311,3 +315,3 @@ //should be the type of the primary key of the referenced table

it('should not alter person column dateOfBirth', function(done) {
var modifiedPersonSchema = _.cloneDeep(personSchema);
modifiedPersonSchema = _.cloneDeep(personSchema);
modifiedPersonSchema.properties.dateOfBirth.type = 'string';

@@ -421,2 +425,21 @@ var person = jsonSchemaTable('person', modifiedPersonSchema, {db: db});

});
it('should alter person column name to text', function(done) {
modifiedPersonSchema.properties.dateOfBirth.type = 'date';
modifiedPersonSchema.properties.name.type = 'text';
delete modifiedPersonSchema.properties.name.type;
var person = jsonSchemaTable('person', modifiedPersonSchema, {db: db});
person.sync()
.then(function() {
return person.metadata()
.then(function(metadata) {
metadata.should.have.property('columns');
expect(metadata.columns).to.be.a('object');
checkColumns(metadata.columns, modifiedPersonSchema);
done();
});
})
.catch(function(error) {
done(error);
});
});
});

@@ -426,2 +449,2 @@

}
};
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