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

Commit 5346495c by Jan Aagaard Meier

Updated dependencies, dottie, inflection, lodash and validator. Also updated cha…

…i, mocha and sinon dev deps
1 parent 0954905f
......@@ -140,7 +140,7 @@ module.exports = (function() {
_.each(this.target.associations, function(association, accessor) {
if (association.associationType !== 'BelongsToMany') return;
if (association.target !== this.source) return;
if (this.options.through.model === association.options.through.model) {
this.paired = association;
}
......@@ -292,7 +292,7 @@ module.exports = (function() {
this.foreignIdentifierField = this.through.model.rawAttributes[this.foreignIdentifier].field || this.foreignIdentifier;
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);
......
......@@ -63,7 +63,7 @@ module.exports = (function() {
var values = {
table: this.quoteTable(tableName),
attributes: attrStr.join(', '),
comments: Utils._.template(comments, { table: this.quoteTable(tableName)})
comments: Utils._.template(comments)({ table: this.quoteTable(tableName)})
};
if (!!options.uniqueKeys) {
......@@ -320,7 +320,7 @@ module.exports = (function() {
when = when || 'unique_violation';
var body = '<%= main %> EXCEPTION WHEN <%= when %> THEN <%= then %>;';
body = Utils._.template(body, {
body = Utils._.template(body)({
main: main,
when: when,
then: then
......
......@@ -85,7 +85,7 @@ module.exports = (function() {
values.attributes += ", PRIMARY KEY (" + pkString + ")";
}
var sql = Utils._.template(query, values).trim() + ";";
var sql = Utils._.template(query)(values).trim() + ";";
return this.replaceBooleanDefaults(sql);
},
......@@ -301,7 +301,7 @@ module.exports = (function() {
showIndexesQuery: function(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) {
......@@ -312,7 +312,7 @@ module.exports = (function() {
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) {
......@@ -322,7 +322,7 @@ module.exports = (function() {
options.quoted = false;
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) {
......@@ -349,7 +349,7 @@ module.exports = (function() {
"DROP TABLE <%= backupTableName %>;"
].join("");
return Utils._.template(query, {
return Utils._.template(query)({
tableName: this.quoteTable(tableName),
backupTableName: this.quoteTable(backupTableName),
attributeNames: Utils._.keys(attributes).join(', ')
......@@ -380,7 +380,7 @@ module.exports = (function() {
"DROP TABLE <%= backupTableName %>;"
].join("");
return Utils._.template(query, {
return Utils._.template(query)({
tableName: this.quoteTable(tableName),
backupTableName: this.quoteTable(backupTableName),
attributeNamesImport: Utils._.keys(attributes).map(function(attr) {
......@@ -437,7 +437,7 @@ module.exports = (function() {
*/
getForeignKeysQuery: function(tableName, schemaName) {
var sql = "PRAGMA foreign_key_list(<%= tableName %>)";
return Utils._.template(sql, { tableName: tableName });
return Utils._.template(sql)({ tableName: tableName });
}
};
......
......@@ -2132,7 +2132,14 @@ module.exports = (function() {
// check if model already included, and skip if so
var model = association.target;
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;
}
......
......@@ -33,36 +33,36 @@
},
"dependencies": {
"bluebird": "2.4.2",
"dottie": "0.2.4",
"dottie": "^0.3.1",
"generic-pool": "2.1.1",
"inflection": "1.5.3",
"lodash": "~2.4.0",
"inflection": "^1.6.0",
"lodash": "^3.5.0",
"moment": "^2.9.0",
"node-uuid": "~1.4.1",
"toposort-class": "~0.3.0",
"validator": "~3.22.1"
"validator": "^3.34.0"
},
"devDependencies": {
"async": "~0.9.0",
"chai": "~1.9.2",
"chai-as-promised": "^4.1.1",
"chai": "^2.1.2",
"chai-as-promised": "^4.3.0",
"chai-datetime": "~1.3.0",
"chai-spies": "~0.5.1",
"coffee-script": "~1.7.1",
"commander": "^2.6.0",
"continuation-local-storage": "3.1.2",
"continuation-local-storage": "^3.1.4",
"dox": "0.5.0",
"git": "^0.1.5",
"istanbul": "~0.3.0",
"jshint": ">=2.4.2",
"lcov-result-merger": "~1.0.0",
"mocha": "~2.0.0",
"mocha": "^2.2.1",
"mysql": "~2.5.0",
"pg": "^4.2.0",
"pg-hstore": "^2.3.1",
"pg-native": "^1.8.0",
"sinon": "~1.11.0",
"sinon-chai": "~2.6.0",
"sinon": "^1.14.1",
"sinon-chai": "^2.7.0",
"sqlite3": "^3.0.5",
"tedious": "^1.7.0",
"watchr": "~2.4.11"
......
......@@ -1867,12 +1867,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
describe('Association options', 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() {
var Project = this.sequelize.define('project', {
user_id: {
type: Sequelize.INTEGER,
defaultValue: 42
}
})
var Project = this.sequelize.define('project', {})
, User = this.sequelize.define('user', {
uid: {
type: Sequelize.INTEGER,
......@@ -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(Project.rawAttributes.user_id.references).to.equal(User.getTableName());
expect(Project.rawAttributes.user_id.referencesKey).to.equal('uid');
expect(Project.rawAttributes.user_id.defaultValue).to.equal(42);
expect(UserProjects.through.model.rawAttributes.user_id).to.be.defined;
expect(UserProjects.through.model.rawAttributes.user_id.references).to.equal(User.getTableName());
expect(UserProjects.through.model.rawAttributes.user_id.referencesKey).to.equal('uid');
expect(UserProjects.through.model.rawAttributes.user_id.defaultValue).to.equal(42);
});
});
......@@ -1924,4 +1919,4 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), function() {
expect(PersonChildren.rawAttributes[Children.otherKey]).to.be.ok;
});
});
});
\ No newline at end of file
});
......@@ -954,14 +954,12 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
});
it('is over-ruled by specified include', function(done) {
this.Country.findAll({ include: [{ all: true }, { model: this.Continent, attributes: ['id'] }] }).done(function(err, countries) {
expect(err).not.to.be.ok;
it('is over-ruled by specified include', function() {
return this.Country.findAll({ include: [{ all: true }, { model: this.Continent, attributes: ['id'] }] }).then(function(countries) {
expect(countries).to.exist;
expect(countries[0]).to.exist;
expect(countries[0].continent).to.exist;
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!