不要怂,就是干,撸起袖子干!

Commit 05a014e3 by Jan Aagaard Meier

Merge pull request #3398 from sequelize/updatedDeps

Updated dependencies, dottie, inflection, lodash and validator. Also upd...
2 parents 09b60285 4d0c581d
# Next # Next
- [BUG] Fix for newlines in hstore [#3383](https://github.com/sequelize/sequelize/issues/3383) - [BUG] Fix for newlines in hstore [#3383](https://github.com/sequelize/sequelize/issues/3383)
- [INTERNALS] Updated dependencies. Most notably we are moving up one major version on lodash. If you are using `sequelize.Utils._`, notice that the semantics for many matching functions have changed to include a check for `hasOwnProperty`
+ dottie@0.3.1
+ inflection@1.6.0
+ lodash@3.5.0
+ validator@3.34
# 2.0.5 # 2.0.5
- [FEATURE] Highly experimental support for nested creation [#3386](https://github.com/sequelize/sequelize/pull/3386) - [FEATURE] Highly experimental support for nested creation [#3386](https://github.com/sequelize/sequelize/pull/3386)
......
...@@ -140,7 +140,7 @@ module.exports = (function() { ...@@ -140,7 +140,7 @@ module.exports = (function() {
_.each(this.target.associations, function(association, accessor) { _.each(this.target.associations, function(association, accessor) {
if (association.associationType !== 'BelongsToMany') return; if (association.associationType !== 'BelongsToMany') return;
if (association.target !== this.source) return; if (association.target !== this.source) return;
if (this.options.through.model === association.options.through.model) { if (this.options.through.model === association.options.through.model) {
this.paired = association; this.paired = association;
} }
...@@ -292,7 +292,7 @@ module.exports = (function() { ...@@ -292,7 +292,7 @@ module.exports = (function() {
this.foreignIdentifierField = this.through.model.rawAttributes[this.foreignIdentifier].field || this.foreignIdentifier; this.foreignIdentifierField = this.through.model.rawAttributes[this.foreignIdentifier].field || this.foreignIdentifier;
if (this.paired && !this.paired.foreignIdentifierField) { if (this.paired && !this.paired.foreignIdentifierField) {
this.paired.foreignIdentifierField = this.through.model.rawAttributes[this.paired.foreignIdentifier].field || this.paired.foreignIdentifier; this.paired.foreignIdentifierField = this.through.model.rawAttributes[this.paired.foreignIdentifier].field || this.paired.foreignIdentifier;
} }
this.through.model.init(this.through.model.daoFactoryManager); this.through.model.init(this.through.model.daoFactoryManager);
......
...@@ -63,7 +63,7 @@ module.exports = (function() { ...@@ -63,7 +63,7 @@ module.exports = (function() {
var values = { var values = {
table: this.quoteTable(tableName), table: this.quoteTable(tableName),
attributes: attrStr.join(', '), attributes: attrStr.join(', '),
comments: Utils._.template(comments, { table: this.quoteTable(tableName)}) comments: Utils._.template(comments)({ table: this.quoteTable(tableName)})
}; };
if (!!options.uniqueKeys) { if (!!options.uniqueKeys) {
...@@ -320,7 +320,7 @@ module.exports = (function() { ...@@ -320,7 +320,7 @@ module.exports = (function() {
when = when || 'unique_violation'; when = when || 'unique_violation';
var body = '<%= main %> EXCEPTION WHEN <%= when %> THEN <%= then %>;'; var body = '<%= main %> EXCEPTION WHEN <%= when %> THEN <%= then %>;';
body = Utils._.template(body, { body = Utils._.template(body)({
main: main, main: main,
when: when, when: when,
then: then then: then
......
...@@ -85,7 +85,7 @@ module.exports = (function() { ...@@ -85,7 +85,7 @@ module.exports = (function() {
values.attributes += ", PRIMARY KEY (" + pkString + ")"; values.attributes += ", PRIMARY KEY (" + pkString + ")";
} }
var sql = Utils._.template(query, values).trim() + ";"; var sql = Utils._.template(query)(values).trim() + ";";
return this.replaceBooleanDefaults(sql); return this.replaceBooleanDefaults(sql);
}, },
...@@ -301,7 +301,7 @@ module.exports = (function() { ...@@ -301,7 +301,7 @@ module.exports = (function() {
showIndexesQuery: function(tableName) { showIndexesQuery: function(tableName) {
var sql = "PRAGMA INDEX_LIST(<%= tableName %>)"; var sql = "PRAGMA INDEX_LIST(<%= tableName %>)";
return Utils._.template(sql, { tableName: this.quoteTable(tableName) }); return Utils._.template(sql)({ tableName: this.quoteTable(tableName) });
}, },
removeIndexQuery: function(tableName, indexNameOrAttributes) { removeIndexQuery: function(tableName, indexNameOrAttributes) {
...@@ -312,7 +312,7 @@ module.exports = (function() { ...@@ -312,7 +312,7 @@ module.exports = (function() {
indexName = Utils.inflection.underscore(tableName + '_' + indexNameOrAttributes.join('_')); indexName = Utils.inflection.underscore(tableName + '_' + indexNameOrAttributes.join('_'));
} }
return Utils._.template(sql, { tableName: this.quoteIdentifiers(tableName), indexName: indexName }); return Utils._.template(sql)( { tableName: this.quoteIdentifiers(tableName), indexName: indexName });
}, },
describeTableQuery: function(tableName, schema, schemaDelimiter) { describeTableQuery: function(tableName, schema, schemaDelimiter) {
...@@ -322,7 +322,7 @@ module.exports = (function() { ...@@ -322,7 +322,7 @@ module.exports = (function() {
options.quoted = false; options.quoted = false;
var sql = "PRAGMA TABLE_INFO(<%= tableName %>);"; var sql = "PRAGMA TABLE_INFO(<%= tableName %>);";
return Utils._.template(sql, { tableName: this.addSchema({tableName: this.quoteIdentifiers(tableName), options: options})}); return Utils._.template(sql)({ tableName: this.addSchema({tableName: this.quoteIdentifiers(tableName), options: options})});
}, },
removeColumnQuery: function(tableName, attributes) { removeColumnQuery: function(tableName, attributes) {
...@@ -349,7 +349,7 @@ module.exports = (function() { ...@@ -349,7 +349,7 @@ module.exports = (function() {
"DROP TABLE <%= backupTableName %>;" "DROP TABLE <%= backupTableName %>;"
].join(""); ].join("");
return Utils._.template(query, { return Utils._.template(query)({
tableName: this.quoteTable(tableName), tableName: this.quoteTable(tableName),
backupTableName: this.quoteTable(backupTableName), backupTableName: this.quoteTable(backupTableName),
attributeNames: Utils._.keys(attributes).join(', ') attributeNames: Utils._.keys(attributes).join(', ')
...@@ -380,7 +380,7 @@ module.exports = (function() { ...@@ -380,7 +380,7 @@ module.exports = (function() {
"DROP TABLE <%= backupTableName %>;" "DROP TABLE <%= backupTableName %>;"
].join(""); ].join("");
return Utils._.template(query, { return Utils._.template(query)({
tableName: this.quoteTable(tableName), tableName: this.quoteTable(tableName),
backupTableName: this.quoteTable(backupTableName), backupTableName: this.quoteTable(backupTableName),
attributeNamesImport: Utils._.keys(attributes).map(function(attr) { attributeNamesImport: Utils._.keys(attributes).map(function(attr) {
...@@ -437,7 +437,7 @@ module.exports = (function() { ...@@ -437,7 +437,7 @@ module.exports = (function() {
*/ */
getForeignKeysQuery: function(tableName, schemaName) { getForeignKeysQuery: function(tableName, schemaName) {
var sql = "PRAGMA foreign_key_list(<%= tableName %>)"; var sql = "PRAGMA foreign_key_list(<%= tableName %>)";
return Utils._.template(sql, { tableName: tableName }); return Utils._.template(sql)({ tableName: tableName });
} }
}; };
......
...@@ -219,6 +219,7 @@ InstanceValidator.prototype._builtinValidators = function() { ...@@ -219,6 +219,7 @@ InstanceValidator.prototype._builtinValidators = function() {
*/ */
InstanceValidator.prototype._customValidators = function() { InstanceValidator.prototype._customValidators = function() {
var validators = []; var validators = [];
var self = this; var self = this;
Utils._.each(this.modelInstance.__options.validate, function(validator, Utils._.each(this.modelInstance.__options.validate, function(validator,
...@@ -254,8 +255,9 @@ InstanceValidator.prototype._builtinAttrValidate = function(value, field) { ...@@ -254,8 +255,9 @@ InstanceValidator.prototype._builtinAttrValidate = function(value, field) {
var validators = []; var validators = [];
Utils._.forIn(this.modelInstance.validators[field], function(test, Utils._.forIn(this.modelInstance.validators[field], function(test,
validatorType) { validatorType) {
if (['isUrl', 'isURL'].indexOf(validatorType) !== -1 && test === true) {
// Preserve backwards compat. Validator.js now expects the second param to isURL to be an object if (['isUrl', 'isURL', 'isEmail'].indexOf(validatorType) !== -1 && test === true) {
// Preserve backwards compat. Validator.js now expects the second param to isURL and isEmail to be an object
test = {}; test = {};
} }
...@@ -328,7 +330,6 @@ InstanceValidator.prototype._invokeCustomValidator = Promise.method(function(val ...@@ -328,7 +330,6 @@ InstanceValidator.prototype._invokeCustomValidator = Promise.method(function(val
* @private * @private
*/ */
InstanceValidator.prototype._invokeBuiltinValidator = Promise.method(function(value, test, validatorType, field) { InstanceValidator.prototype._invokeBuiltinValidator = Promise.method(function(value, test, validatorType, field) {
// check if Validator knows that kind of validation test // check if Validator knows that kind of validation test
if (typeof Validator[validatorType] !== 'function') { if (typeof Validator[validatorType] !== 'function') {
throw new Error('Invalid validator function: ' + validatorType); throw new Error('Invalid validator function: ' + validatorType);
...@@ -347,6 +348,7 @@ InstanceValidator.prototype._invokeBuiltinValidator = Promise.method(function(va ...@@ -347,6 +348,7 @@ InstanceValidator.prototype._invokeBuiltinValidator = Promise.method(function(va
validatorArgs = validatorArgs.slice(0); validatorArgs = validatorArgs.slice(0);
} }
validatorArgs.push(field); validatorArgs.push(field);
if (!Validator[validatorType].apply(Validator, [value].concat(validatorArgs))) { if (!Validator[validatorType].apply(Validator, [value].concat(validatorArgs))) {
throw errorMessage; throw errorMessage;
} }
......
...@@ -2136,7 +2136,14 @@ module.exports = (function() { ...@@ -2136,7 +2136,14 @@ module.exports = (function() {
// check if model already included, and skip if so // check if model already included, and skip if so
var model = association.target; var model = association.target;
var as = association.options.as; var as = association.options.as;
if (Utils._.find(includes, {model: model, as: as})) {
var predicate = {model: model};
if (as) {
// We only add 'as' to the predicate if it actually exists
predicate.as = as;
}
if (Utils._.find(includes, predicate)) {
return; return;
} }
......
...@@ -33,36 +33,36 @@ ...@@ -33,36 +33,36 @@
}, },
"dependencies": { "dependencies": {
"bluebird": "2.4.2", "bluebird": "2.4.2",
"dottie": "0.2.4", "dottie": "^0.3.1",
"generic-pool": "2.1.1", "generic-pool": "2.1.1",
"inflection": "1.5.3", "inflection": "^1.6.0",
"lodash": "~2.4.0", "lodash": "^3.5.0",
"moment": "^2.9.0", "moment": "^2.9.0",
"node-uuid": "~1.4.1", "node-uuid": "~1.4.1",
"toposort-class": "~0.3.0", "toposort-class": "~0.3.0",
"validator": "~3.22.1" "validator": "^3.34.0"
}, },
"devDependencies": { "devDependencies": {
"async": "~0.9.0", "async": "~0.9.0",
"chai": "~1.9.2", "chai": "^2.1.2",
"chai-as-promised": "^4.1.1", "chai-as-promised": "^4.3.0",
"chai-datetime": "~1.3.0", "chai-datetime": "~1.3.0",
"chai-spies": "~0.5.1", "chai-spies": "~0.5.1",
"coffee-script": "~1.7.1", "coffee-script": "~1.7.1",
"commander": "^2.6.0", "commander": "^2.6.0",
"continuation-local-storage": "3.1.2", "continuation-local-storage": "^3.1.4",
"dox": "0.5.0", "dox": "0.5.0",
"git": "^0.1.5", "git": "^0.1.5",
"istanbul": "~0.3.0", "istanbul": "~0.3.0",
"jshint": ">=2.4.2", "jshint": ">=2.4.2",
"lcov-result-merger": "~1.0.0", "lcov-result-merger": "~1.0.0",
"mocha": "~2.0.0", "mocha": "^2.2.1",
"mysql": "~2.5.0", "mysql": "~2.5.0",
"pg": "^4.2.0", "pg": "^4.2.0",
"pg-hstore": "^2.3.1", "pg-hstore": "^2.3.1",
"pg-native": "^1.8.0", "pg-native": "^1.8.0",
"sinon": "~1.11.0", "sinon": "^1.14.1",
"sinon-chai": "~2.6.0", "sinon-chai": "^2.7.0",
"sqlite3": "^3.0.5", "sqlite3": "^3.0.5",
"tedious": "^1.7.0", "tedious": "^1.7.0",
"watchr": "~2.4.11" "watchr": "~2.4.11"
......
...@@ -1867,12 +1867,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() { ...@@ -1867,12 +1867,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
describe('Association options', function() { describe('Association options', function() {
describe('allows the user to provide an attribute definition object as foreignKey', function() { describe('allows the user to provide an attribute definition object as foreignKey', function() {
it('works when taking a column directly from the object', function() { it('works when taking a column directly from the object', function() {
var Project = this.sequelize.define('project', { var Project = this.sequelize.define('project', {})
user_id: {
type: Sequelize.INTEGER,
defaultValue: 42
}
})
, User = this.sequelize.define('user', { , User = this.sequelize.define('user', {
uid: { uid: {
type: Sequelize.INTEGER, type: Sequelize.INTEGER,
...@@ -1880,12 +1875,12 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() { ...@@ -1880,12 +1875,12 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
} }
}); });
User.belongsToMany(Project, { foreignKey: Project.rawAttributes.user_id}); var UserProjects = User.belongsToMany(Project, { foreignKey: { name: 'user_id', defaultValue: 42 }});
expect(Project.rawAttributes.user_id).to.be.defined; expect(UserProjects.through.model.rawAttributes.user_id).to.be.defined;
expect(Project.rawAttributes.user_id.references).to.equal(User.getTableName()); expect(UserProjects.through.model.rawAttributes.user_id.references).to.equal(User.getTableName());
expect(Project.rawAttributes.user_id.referencesKey).to.equal('uid'); expect(UserProjects.through.model.rawAttributes.user_id.referencesKey).to.equal('uid');
expect(Project.rawAttributes.user_id.defaultValue).to.equal(42); expect(UserProjects.through.model.rawAttributes.user_id.defaultValue).to.equal(42);
}); });
}); });
...@@ -1924,4 +1919,4 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() { ...@@ -1924,4 +1919,4 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
expect(PersonChildren.rawAttributes[Children.otherKey]).to.be.ok; expect(PersonChildren.rawAttributes[Children.otherKey]).to.be.ok;
}); });
}); });
}); });
\ No newline at end of file
...@@ -954,14 +954,12 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -954,14 +954,12 @@ describe(Support.getTestDialectTeaser('Model'), function() {
}); });
}); });
it('is over-ruled by specified include', function(done) { it('is over-ruled by specified include', function() {
this.Country.findAll({ include: [{ all: true }, { model: this.Continent, attributes: ['id'] }] }).done(function(err, countries) { return this.Country.findAll({ include: [{ all: true }, { model: this.Continent, attributes: ['id'] }] }).then(function(countries) {
expect(err).not.to.be.ok;
expect(countries).to.exist; expect(countries).to.exist;
expect(countries[0]).to.exist; expect(countries[0]).to.exist;
expect(countries[0].continent).to.exist; expect(countries[0].continent).to.exist;
expect(countries[0].continent.name).to.be.undefined; expect(countries[0].continent.name).to.be.undefined;
done();
}); });
}); });
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!