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

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
...@@ -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 });
} }
}; };
......
...@@ -2132,7 +2132,14 @@ module.exports = (function() { ...@@ -2132,7 +2132,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);
}); });
}); });
......
...@@ -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!