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

Commit 51035b13 by Jan Aagaard Meier

More changelog entries to the correct place, fix the remaining test

1 parent 2210ce44
......@@ -2,7 +2,16 @@ Notice: All 1.7.x changes are present in 2.0.x aswell
# Next
- [FEATURE] Added to option of setting a timezone offset in the sequelize constructor (`timezone` option). This timezone is used when initializing a connection (using `SET TIME ZONE` or equivalent), and when converting a timestamp string from the DB to a JS date with mysql (postgres stores the timezone, so for postgres we rely on what's in the DB).
- [FEATURE] Allow setting plural and singular name on the model (`options.name` in `sequelize.define`) and in associations (`options.as`) to circumvent issues with weird pluralization.
- [INTERNALS] Replaced lingo with inflection
- [INTERNALS] Removed underscore.string dependency and moved a couple of helper functions from `Utils._` to `Utils`
#### Backwards compatability changes
- We are using a new inflection library, which should make pluralization and singularization in general more robust. However, a couple of pluralizations have changed as a result:
+ Person is now pluralized as people instead of persons
- Accesors for models with underscored names are no longer camel cased automatically. For example, if you have a model with name `my_model`, and `my_other_model.hasMany(my_model)`, the getter will now be `instance_of_my_model.getMy_model` instead of `.getMyModel`.
- Removed support for setting sequelize.language. If your model names are not in english, use the name option provided by `sequelize.name` to defined singular and plural forms for your model.
- Model names are now used more verbatim in associations. This means that if you have a model named `Task` (plural T), or an association specifying `{ as: 'Task' }`, the tasks will be returned as `relatedModel.Tasks` instead of `relatedModel.tasks`. For more information and how to mitigate this, see https://github.com/sequelize/sequelize/wiki/Upgrading-to-2.0#inflection-replaces-lingo-and-changes-to-naming-conventions
# v2.0.0-dev12
- [FEATURE] You can now return a promise to a hook rather than use a callback
......@@ -24,9 +33,6 @@ Notice: All 1.7.x changes are present in 2.0.x aswell
- [BUG] Use the provided name for a unique index if one is given, instead of concating the column names together [#1944](https://github.com/sequelize/sequelize/issues/1944)
- [BUG] Create a composite primary key for doubled linked self reference [#1891](https://github.com/sequelize/sequelize/issues/1891)
- [INTERNALS] `bulkDeleteQuery` was removed from the MySQL / abstract query generator, since it was never used internally. Please use `deleteQuery` instead.
- [INTERNALS] Replaced lingo with inflection
- [INTERNALS] Removed underscore.string dependency and moved a couple of helper functions from `Utils._` to `Utils`
#### Backwards compatability changes
- Sequelize now returns promises instead of its custom event emitter from most calls. This affects methods that return multiple values (like `findOrCreate` or `findOrInitialize`). If your current callbacks do not accept the 2nd success parameter you might be seeing an array as the first param. Either use `.spread()` for these methods or add another argument to your callback: `.success(instance)` -> `.success(instance, created)`.
......@@ -37,10 +43,6 @@ Notice: All 1.7.x changes are present in 2.0.x aswell
- `sequelize.transaction()` now returns a promise rather than a instance of Sequelize.Transaction
- `bulkCreate`, `bulkUpdate` and `bulkDestroy` (and aliases) now take both a `hooks` and an `individualHooks` option, `hooks` defines whether or not to run the main hooks, and `individualHooks` defines whether to run hooks for each instance affected.
- It is no longer possible to disable pooling, disable pooling will just result in a 1/1 pool.
- We are using a new inflection library, which should make pluralization and singularization in general more robust. However, a couple of pluralizations have changed as a result:
+ Person is now pluralized as people instead of persons
- Accesors for models with underscored names are no longer camel cased automatically. For example, if you have a model with name `my_model`, and `my_other_model` hasMany `my_model`, the getter will now be `getMy_model` instead of `getMyModel`.
- Removed support for setting sequelize.language. If your model names are not in english, use the name option provided by `sequelize.name` to defined singular and plural forms for your model.
# v2.0.0-dev11
### Caution: This release contains many changes and is highly experimental
......
......@@ -632,4 +632,3 @@ Utils.col.prototype.toString = function(queryGenerator, parentModel) {
Utils.CustomEventEmitter = require(__dirname + '/emitters/custom-event-emitter');
Utils.Promise = require(__dirname + '/promise');
Utils.QueryChainer = require(__dirname + '/query-chainer');
Utils.Lingo = require('lingo');
"use strict";
/* jshint camelcase: false, expr: true */
var chai = require('chai')
, expect = chai.expect
, Support = require(__dirname + '/../support')
, DataTypes = require(__dirname + "/../../lib/data-types")
, Sequelize = require('../../index')
, Promise = Sequelize.Promise
, assert = require('assert');
chai.config.includeStack = true;
describe(Support.getTestDialectTeaser("Alias"), function() {
it('should uppercase the first letter in alias getter, but not in eager loading', function () {
var User = this.sequelize.define('user', {})
, Task = this.sequelize.define('task', {});
User.hasMany(Task, { as: 'assignments', foreignKey: 'userId' });
Task.belongsTo(User, { as: 'owner', foreignKey: 'userId' });
return this.sequelize.sync({ force: true }).then(function () {
return Promise.all([
User.create({ id: 1 }),
Task.create({ id: 1, userId: 1 })
]);
}).spread(function (user, task) {
expect(user.getAssignments).to.be.ok;
expect(task.getOwner).to.be.ok;
}).then(function () {
return Promise.all([
User.find({ where: { id: 1 }, include: [{model: Task, as: 'assignments'}] }),
Task.find({ where: { id: 1 }, include: [{model: User, as: 'owner'}] }),
]);
}).spread(function (user, task) {
expect(user.assignments).to.be.ok;
expect(task.owner).to.be.ok;
});
});
it('shouldnt touch the passed alias', function () {
var User = this.sequelize.define('user', {})
, Task = this.sequelize.define('task', {});
User.hasMany(Task, { as: 'ASSIGNMENTS', foreignKey: 'userId' });
Task.belongsTo(User, { as: 'OWNER', foreignKey: 'userId' });
return this.sequelize.sync({ force: true }).then(function () {
return User.create({ id: 1 });
}).then(function (user){
expect(user.getASSIGNMENTS).to.be.ok;
return Task.create({ id: 1, userId: 1 });
}).then(function (task) {
expect(task.getOWNER).to.be.ok;
return Promise.all([
User.find({ where: { id: 1 }, include: [{model: Task, as: 'ASSIGNMENTS'}] }),
Task.find({ where: { id: 1 }, include: [{model: User, as: 'OWNER'}] }),
]);
}).spread(function (user, task) {
expect(user.ASSIGNMENTS).to.be.ok;
expect(task.OWNER).to.be.ok;
});
});
it('should allow me to pass my own plural and singular forms to hasMany', function () {
var User = this.sequelize.define('user', {})
, Task = this.sequelize.define('task', {});
User.hasMany(Task, { as: { singular: 'task', plural: 'taskz'} });
return this.sequelize.sync({ force: true }).then(function () {
return Promise.all([
User.create({ id: 1 }),
]);
}).spread(function (user, task) {
expect(user.getTaskz).to.be.ok;
expect(user.addTask).to.be.ok;
expect(user.addTaskz).to.be.ok;
}).then(function () {
return Promise.all([
User.find({ where: { id: 1 }, include: [{model: Task, as: 'taskz'}] }),
]);
}).spread(function (user, task) {
expect(user.taskz).to.be.ok;
});
});
it('should allow me to define plural and singular forms on the model', function () {
var User = this.sequelize.define('user', {})
, Task = this.sequelize.define('task', {}, {
name: {
singular: 'assignment',
plural: 'assignments'
}
});
User.hasMany(Task);
return this.sequelize.sync({ force: true }).then(function () {
return Promise.all([
User.create({ id: 1 }),
]);
}).spread(function (user, task) {
expect(user.getAssignments).to.be.ok;
expect(user.addAssignment).to.be.ok;
expect(user.addAssignments).to.be.ok;
}).then(function () {
return Promise.all([
User.find({ where: { id: 1 }, include: [Task] }),
]);
}).spread(function (user, task) {
expect(user.assignments).to.be.ok;
});
});
});
......@@ -465,11 +465,11 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
var product = Product.build({
id: 1,
title: 'Chair',
tags: [
Tags: [
{id: 1, name: 'Alpha'},
{id: 2, name: 'Beta'}
],
user: {
User: {
id: 1,
first_name: 'Mick',
last_name: 'Hansen'
......@@ -527,8 +527,8 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
]
}, {
include: [
{model: User, as: 'Followers'},
{model: Tag, as: 'Categories'}
{model: User, as: 'followers'},
{model: Tag, as: 'categories'}
]
})
......
......@@ -1226,14 +1226,14 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
self.User.findAll({include: [ { model: self.Project, as: 'Projects' } ]}).success(function(users) {
var _user = users[0]
expect(_user.projects).to.exist
expect(JSON.parse(JSON.stringify(_user)).projects).to.exist
expect(_user.Projects).to.exist
expect(JSON.parse(JSON.stringify(_user)).Projects).to.exist
self.Project.findAll({include: [ { model: self.User, as: 'LovelyUser' } ]}).success(function(projects) {
var _project = projects[0]
expect(_project.lovelyUser).to.exist
expect(JSON.parse(JSON.stringify(_project)).lovelyUser).to.exist
expect(_project.LovelyUser).to.exist
expect(JSON.parse(JSON.stringify(_project)).LovelyUser).to.exist
done()
})
......
......@@ -139,8 +139,8 @@ describe(Support.getTestDialectTeaser("Include"), function () {
]
}).done(function (err, task) {
expect(err).not.to.be.ok
expect(task.user).to.be.ok
expect(task.group).to.be.ok
expect(task.User).to.be.ok
expect(task.Group).to.be.ok
done()
})
})
......@@ -187,7 +187,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
}).done(function (err, group) {
expect(err).not.to.be.ok
expect(group.User).to.be.ok
expect(group.User.task).to.be.ok
expect(group.User.Task).to.be.ok
done()
})
})
......@@ -240,7 +240,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
expect(user.Tasks).to.be.ok
expect(user.Tasks.length).to.equal(4)
user.tasks.forEach(function (task) {
user.Tasks.forEach(function (task) {
expect(task.Project).to.be.ok
})
......@@ -295,8 +295,8 @@ describe(Support.getTestDialectTeaser("Include"), function () {
}).done(function (err, worker) {
expect(err).not.to.be.ok
expect(worker.Project).to.be.ok
expect(worker.Project.tasks).to.be.ok
expect(worker.Project.tasks.length).to.equal(4)
expect(worker.Project.Tasks).to.be.ok
expect(worker.Project.Tasks.length).to.equal(4)
done()
})
......@@ -373,10 +373,10 @@ describe(Support.getTestDialectTeaser("Include"), function () {
expect(err).not.to.be.ok
expect(user.Products.length).to.equal(4)
expect(user.Products[0].tags.length).to.equal(2)
expect(user.Products[1].tags.length).to.equal(1)
expect(user.Products[2].tags.length).to.equal(3)
expect(user.Products[3].tags.length).to.equal(0)
expect(user.Products[0].Tags.length).to.equal(2)
expect(user.Products[1].Tags.length).to.equal(1)
expect(user.Products[2].Tags.length).to.equal(3)
expect(user.Products[3].Tags.length).to.equal(0)
done()
})
})
......@@ -516,20 +516,20 @@ describe(Support.getTestDialectTeaser("Include"), function () {
}).done(function (err, user) {
user.Memberships.sort(sortById)
expect(user.Memberships.length).to.equal(2)
expect(user.Memberships[0].group.name).to.equal('Developers')
expect(user.Memberships[0].rank.canRemove).to.equal(1)
expect(user.Memberships[1].group.name).to.equal('Designers')
expect(user.Memberships[1].rank.canRemove).to.equal(0)
expect(user.Memberships[0].Group.name).to.equal('Developers')
expect(user.Memberships[0].Rank.canRemove).to.equal(1)
expect(user.Memberships[1].Group.name).to.equal('Designers')
expect(user.Memberships[1].Rank.canRemove).to.equal(0)
user.Products.sort(sortById)
expect(user.Products.length).to.equal(2)
expect(user.Products[0].tags.length).to.equal(2)
expect(user.Products[1].tags.length).to.equal(1)
expect(user.Products[0].category).to.be.ok
expect(user.Products[1].category).not.to.be.ok
expect(user.Products[0].Tags.length).to.equal(2)
expect(user.Products[1].Tags.length).to.equal(1)
expect(user.Products[0].Category).to.be.ok
expect(user.Products[1].Category).not.to.be.ok
expect(user.Products[0].prices.length).to.equal(2)
expect(user.Products[1].prices.length).to.equal(4)
expect(user.Products[0].Prices.length).to.equal(2)
expect(user.Products[1].Prices.length).to.equal(4)
done()
})
......@@ -566,7 +566,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
expect(tasks[0].title).to.equal('FooBar')
expect(tasks[0].Project.title).to.equal('BarFoo');
expect(_.omit(tasks[0].get(), 'project')).to.deep.equal({ title: 'FooBar' })
expect(_.omit(tasks[0].get(), 'Project')).to.deep.equal({ title: 'FooBar' })
expect(tasks[0].Project.get()).to.deep.equal({ title: 'BarFoo'})
done()
......
......@@ -3,6 +3,7 @@
var chai = require('chai')
, expect = chai.expect
, Support = require(__dirname + '/../support')
, Sequelize = require(__dirname + '/../../index')
, DataTypes = require(__dirname + "/../../lib/data-types")
, datetime = require('chai-datetime')
, async = require('async');
......@@ -52,10 +53,10 @@ describe(Support.getTestDialectTeaser("Include"), function () {
});
it("should still pull the main record when an included model is not required and has where restrictions without matches", function () {
var A = this.sequelize.define('A', {
var A = this.sequelize.define('a', {
name: DataTypes.STRING(40)
})
, B = this.sequelize.define('B', {
, B = this.sequelize.define('b', {
name: DataTypes.STRING(40)
});
......@@ -84,16 +85,16 @@ describe(Support.getTestDialectTeaser("Include"), function () {
});
it('should support many levels of belongsTo (with a lower level having a where)', function (done) {
var A = this.sequelize.define('A', {})
, B = this.sequelize.define('B', {})
, C = this.sequelize.define('C', {})
, D = this.sequelize.define('D', {})
, E = this.sequelize.define('E', {})
, F = this.sequelize.define('F', {})
, G = this.sequelize.define('G', {
var A = this.sequelize.define('a', {})
, B = this.sequelize.define('b', {})
, C = this.sequelize.define('c', {})
, D = this.sequelize.define('d', {})
, E = this.sequelize.define('e', {})
, F = this.sequelize.define('f', {})
, G = this.sequelize.define('g', {
name: DataTypes.STRING
})
, H = this.sequelize.define('H', {
, H = this.sequelize.define('h', {
name: DataTypes.STRING
});
......@@ -126,12 +127,12 @@ describe(Support.getTestDialectTeaser("Include"), function () {
async.eachSeries(singles, function (model, callback) {
var values = {};
if (model.name === 'G') {
if (model.name === 'g') {
values.name = 'yolo';
}
model.create(values).done(function (err, instance) {
if (previousInstance) {
previousInstance["set"+model.name](instance).done(function () {
previousInstance["set"+Sequelize.Utils.uppercaseFirst(model.name)](instance).done(function () {
previousInstance = instance;
callback();
});
......@@ -174,4 +175,4 @@ describe(Support.getTestDialectTeaser("Include"), function () {
});
});
});
});
\ No newline at end of file
});
......@@ -394,23 +394,23 @@ describe(Support.getTestDialectTeaser("Include"), function () {
}).done(function (err, users) {
expect(err).not.to.be.ok
users.forEach(function (user) {
user.memberships.sort(sortById)
user.Memberships.sort(sortById)
expect(user.memberships.length).to.equal(2)
expect(user.memberships[0].group.name).to.equal('Developers')
expect(user.memberships[0].rank.canRemove).to.equal(1)
expect(user.memberships[1].group.name).to.equal('Designers')
expect(user.memberships[1].rank.canRemove).to.equal(0)
expect(user.Memberships.length).to.equal(2)
expect(user.Memberships[0].Group.name).to.equal('Developers')
expect(user.Memberships[0].Rank.canRemove).to.equal(1)
expect(user.Memberships[1].Group.name).to.equal('Designers')
expect(user.Memberships[1].Rank.canRemove).to.equal(0)
user.products.sort(sortById)
expect(user.products.length).to.equal(2)
expect(user.products[0].tags.length).to.equal(2)
expect(user.products[1].tags.length).to.equal(1)
expect(user.products[0].category).to.be.ok
expect(user.products[1].category).not.to.be.ok
user.Products.sort(sortById)
expect(user.Products.length).to.equal(2)
expect(user.Products[0].Tags.length).to.equal(2)
expect(user.Products[1].Tags.length).to.equal(1)
expect(user.Products[0].Category).to.be.ok
expect(user.Products[1].Category).not.to.be.ok
expect(user.products[0].prices.length).to.equal(2)
expect(user.products[1].prices.length).to.equal(4)
expect(user.Products[0].Prices.length).to.equal(2)
expect(user.Products[1].Prices.length).to.equal(4)
done()
})
......@@ -423,14 +423,14 @@ describe(Support.getTestDialectTeaser("Include"), function () {
})
it('should support many levels of belongsTo', function (done) {
var A = this.sequelize.define('A', {})
, B = this.sequelize.define('B', {})
, C = this.sequelize.define('C', {})
, D = this.sequelize.define('D', {})
, E = this.sequelize.define('E', {})
, F = this.sequelize.define('F', {})
, G = this.sequelize.define('G', {})
, H = this.sequelize.define('H', {})
var A = this.sequelize.define('a', {})
, B = this.sequelize.define('b', {})
, C = this.sequelize.define('c', {})
, D = this.sequelize.define('d', {})
, E = this.sequelize.define('e', {})
, F = this.sequelize.define('f', {})
, G = this.sequelize.define('g', {})
, H = this.sequelize.define('h', {})
A.belongsTo(B)
B.belongsTo(C)
......@@ -472,7 +472,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
async.eachSeries(singles, function (model, callback) {
model.create({}).done(function (err, instance) {
if (previousInstance) {
previousInstance["set"+model.name](instance).done(function () {
previousInstance["set"+Sequelize.Utils.uppercaseFirst(model.name)](instance).done(function () {
previousInstance = instance
callback()
})
......@@ -524,16 +524,16 @@ describe(Support.getTestDialectTeaser("Include"), function () {
})
it('should support many levels of belongsTo (with a lower level having a where)', function (done) {
var A = this.sequelize.define('A', {})
, B = this.sequelize.define('B', {})
, C = this.sequelize.define('C', {})
, D = this.sequelize.define('D', {})
, E = this.sequelize.define('E', {})
, F = this.sequelize.define('F', {})
, G = this.sequelize.define('G', {
var A = this.sequelize.define('a', {})
, B = this.sequelize.define('b', {})
, C = this.sequelize.define('c', {})
, D = this.sequelize.define('d', {})
, E = this.sequelize.define('e', {})
, F = this.sequelize.define('f', {})
, G = this.sequelize.define('g', {
name: DataTypes.STRING
})
, H = this.sequelize.define('H', {
, H = this.sequelize.define('h', {
name: DataTypes.STRING
})
......@@ -577,12 +577,12 @@ describe(Support.getTestDialectTeaser("Include"), function () {
async.eachSeries(singles, function (model, callback) {
var values = {};
if (model.name === 'G') {
if (model.name === 'g') {
values.name = 'yolo';
}
model.create(values).done(function (err, instance) {
if (previousInstance) {
previousInstance["set"+model.name](instance).done(function () {
previousInstance["set"+Sequelize.Utils.uppercaseFirst(model.name)](instance).done(function () {
previousInstance = instance
callback()
})
......@@ -702,7 +702,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
}]
}, function() {
User.findAll({
'where': {'itemA.test': 'abc'},
'where': {'itemA.test': 'abc'},
'include': [
{'model': Item, 'as': 'itemA'},
{'model': Item, 'as': 'itemB'},
......@@ -715,8 +715,8 @@ describe(Support.getTestDialectTeaser("Include"), function () {
expect(as[0].itemA.test).to.eql('abc')
expect(as[1].itemA.test).to.eql('abc')
expect(as[0].order.position).to.eql(1)
expect(as[1].order.position).to.eql(2)
expect(as[0].Order.position).to.eql(1)
expect(as[1].Order.position).to.eql(2)
done()
})
......@@ -786,14 +786,14 @@ describe(Support.getTestDialectTeaser("Include"), function () {
}).done(function (err, products) {
expect(err).not.to.be.ok
expect(products[0].tags[0].productTag.priority).to.equal(1)
expect(products[0].tags[1].productTag.priority).to.equal(2)
expect(products[0].Tags[0].ProductTag.priority).to.equal(1)
expect(products[0].Tags[1].ProductTag.priority).to.equal(2)
expect(products[1].tags[0].productTag.priority).to.equal(1)
expect(products[1].Tags[0].ProductTag.priority).to.equal(1)
expect(products[2].tags[0].productTag.priority).to.equal(3)
expect(products[2].tags[1].productTag.priority).to.equal(1)
expect(products[2].tags[2].productTag.priority).to.equal(2)
expect(products[2].Tags[0].ProductTag.priority).to.equal(3)
expect(products[2].Tags[1].ProductTag.priority).to.equal(1)
expect(products[2].Tags[2].ProductTag.priority).to.equal(2)
done()
})
......@@ -832,7 +832,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
}).done(function (err, users) {
expect(err).not.to.be.ok
expect(users.length).to.equal(1)
expect(users[0].group).to.be.ok
expect(users[0].Group).to.be.ok
done()
})
})
......@@ -878,8 +878,8 @@ describe(Support.getTestDialectTeaser("Include"), function () {
}).done(function (err, users) {
expect(err).not.to.be.ok
expect(users.length).to.equal(1)
expect(users[0].group).to.be.ok
expect(users[0].group.name).to.equal('A')
expect(users[0].Group).to.be.ok
expect(users[0].Group.name).to.equal('A')
done()
})
})
......@@ -925,7 +925,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
}).done(function (err, users) {
expect(err).not.to.be.ok
users.forEach(function (user) {
expect(user.group).to.be.ok
expect(user.Group).to.be.ok
})
done()
})
......@@ -944,7 +944,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
// Associate
User.belongsTo( Address, { foreignKey: 'addressId' })
Address.hasMany( User, { foreignKey: 'addressId' })
Address.belongsTo( Street, { foreignKey: 'streetId' })
Street.hasMany( Address, { foreignKey: 'streetId' })
......@@ -966,8 +966,8 @@ describe(Support.getTestDialectTeaser("Include"), function () {
]
}).done(function (err, john) {
expect(err).not.to.be.ok
expect(john.address).to.be.ok
expect(john.address.street).to.be.ok
expect(john.Address).to.be.ok
expect(john.Address.Street).to.be.ok
done();
})
......@@ -1039,8 +1039,8 @@ describe(Support.getTestDialectTeaser("Include"), function () {
expect(err).not.to.be.ok
expect(users.length).to.equal(1)
users.forEach(function (user) {
expect(user.group).to.be.ok
expect(user.group.categories).to.be.ok
expect(user.Group).to.be.ok
expect(user.Group.Categories).to.be.ok
})
done()
})
......@@ -1109,8 +1109,8 @@ describe(Support.getTestDialectTeaser("Include"), function () {
expect(err).not.to.be.ok
expect(users.length).to.equal(1)
users.forEach(function (user) {
expect(user.team).to.be.ok
expect(user.team.tags).to.be.ok
expect(user.Team).to.be.ok
expect(user.Team.Tags).to.be.ok
})
done()
})
......@@ -1179,8 +1179,8 @@ describe(Support.getTestDialectTeaser("Include"), function () {
expect(err).not.to.be.ok
expect(users.length).to.equal(1)
users.forEach(function (user) {
expect(user.group).to.be.ok
expect(user.group.categories).to.be.ok
expect(user.Group).to.be.ok
expect(user.Group.Categories).to.be.ok
})
done()
})
......@@ -1227,8 +1227,8 @@ describe(Support.getTestDialectTeaser("Include"), function () {
}).done(function (err, users) {
expect(err).not.to.be.ok
expect(users.length).to.equal(1)
expect(users[0].leaderOf).to.be.ok
expect(users[0].leaderOf.title).to.equal('Beta')
expect(users[0].LeaderOf).to.be.ok
expect(users[0].LeaderOf.title).to.equal('Beta')
done()
})
})
......@@ -1294,7 +1294,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
expect(err).not.to.be.ok
expect(products.length).to.equal(1)
expect(products[0].tags.length).to.equal(1)
expect(products[0].Tags.length).to.equal(1)
done()
})
......@@ -1466,12 +1466,12 @@ describe(Support.getTestDialectTeaser("Include"), function () {
]
}).done(function (err, users) {
expect(err).not.to.be.ok
users.forEach(function (user) {
expect(user.memberships.length).to.equal(1)
expect(user.memberships[0].rank.name).to.equal('Admin')
expect(user.products.length).to.equal(1)
expect(user.products[0].prices.length).to.equal(1)
expect(user.Memberships.length).to.equal(1)
expect(user.Memberships[0].Rank.name).to.equal('Admin')
expect(user.Products.length).to.equal(1)
expect(user.Products[0].Prices.length).to.equal(1)
})
done()
......@@ -1527,7 +1527,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
expect(users.length).to.equal(2)
users.forEach(function (user) {
expect(user.group.name).to.equal('A')
expect(user.Group.name).to.equal('A')
})
done()
})
......@@ -1554,9 +1554,9 @@ describe(Support.getTestDialectTeaser("Include"), function () {
expect(products.length).to.equal(3)
products.forEach(function (product) {
expect(product.company.name).to.equal('NYSE')
expect(product.tags.length).to.be.ok
expect(product.prices.length).to.be.ok
expect(product.Company.name).to.equal('NYSE')
expect(product.Tags.length).to.be.ok
expect(product.Prices.length).to.be.ok
})
done()
})
......@@ -1606,8 +1606,8 @@ describe(Support.getTestDialectTeaser("Include"), function () {
expect(err).not.to.be.ok
products.forEach(function (product) {
expect(product.tags.length).to.be.ok
product.tags.forEach(function (tag) {
expect(product.Tags.length).to.be.ok
product.Tags.forEach(function (tag) {
expect(tag.get().productTags).not.to.be.ok
})
})
......@@ -1657,7 +1657,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
var members = []
, albums = []
, memberCount = 20
for(var i = 1;i <= memberCount;i++) {
members.push({
id: i,
......@@ -1669,7 +1669,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
MemberId: i
});
}
Member.bulkCreate(members).done(function (err) {
expect(err).not.to.be.ok;
Album.bulkCreate(albums).done(function (err) {
......@@ -1687,7 +1687,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
expect(members.length).to.equal(20);
members.forEach(function (member) {
expect(member.get('id')).not.to.be.ok;
expect(member.albums.length).to.equal(1);
expect(member.Albums.length).to.equal(1);
});
done();
......@@ -1718,10 +1718,10 @@ describe(Support.getTestDialectTeaser("Include"), function () {
expect(products.length).to.equal(6)
products.forEach(function (product) {
expect(product.tags.length).to.be.ok
expect(product.prices.length).to.be.ok
expect(product.Tags.length).to.be.ok
expect(product.Prices.length).to.be.ok
product.prices.forEach(function (price) {
product.Prices.forEach(function (price) {
expect(price.value).to.be.above(5)
})
})
......@@ -1748,10 +1748,10 @@ describe(Support.getTestDialectTeaser("Include"), function () {
expect(products.length).to.equal(10)
products.forEach(function (product) {
expect(product.tags.length).to.be.ok
expect(product.prices.length).to.be.ok
expect(product.Tags.length).to.be.ok
expect(product.Prices.length).to.be.ok
product.tags.forEach(function (tag) {
product.Tags.forEach(function (tag) {
expect(['A', 'B', 'C']).to.include(tag.name)
})
})
......@@ -1778,12 +1778,12 @@ describe(Support.getTestDialectTeaser("Include"), function () {
User.findAll({
where: {
id: user.id
},
},
include: [Group]
}).success(function (users) {
expect(users[0].dateField.getTime()).to.equal(Date.UTC(2014, 1, 20))
expect(users[0].groups[0].dateField.getTime()).to.equal(Date.UTC(2014, 1, 20))
done()
})
})
......@@ -1794,8 +1794,8 @@ describe(Support.getTestDialectTeaser("Include"), function () {
it("should still pull the main record(s) when an included model is not required and has where restrictions without matches", function () {
var self = this
, A = this.sequelize.define( 'A', {name: DataTypes.STRING(40)} )
, B = this.sequelize.define( 'B', {name: DataTypes.STRING(40)} );
, A = this.sequelize.define( 'a', {name: DataTypes.STRING(40)} )
, B = this.sequelize.define( 'b', {name: DataTypes.STRING(40)} );
A.hasMany(B);
B.hasMany(A);
......@@ -1824,4 +1824,4 @@ describe(Support.getTestDialectTeaser("Include"), function () {
})
})
\ No newline at end of file
})
......@@ -239,7 +239,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
})
}
})
it('should support an include with multiple different association types', function (done) {
var self = this
......@@ -403,24 +403,24 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
}).done(function (err, users) {
expect(err).not.to.be.ok
users.forEach(function (user) {
expect(user.memberships).to.be.ok
user.memberships.sort(sortById)
expect(user.Memberships).to.be.ok
user.Memberships.sort(sortById)
expect(user.memberships.length).to.equal(2)
expect(user.memberships[0].group.name).to.equal('Developers')
expect(user.memberships[0].rank.canRemove).to.equal(1)
expect(user.memberships[1].group.name).to.equal('Designers')
expect(user.memberships[1].rank.canRemove).to.equal(0)
expect(user.Memberships.length).to.equal(2)
expect(user.Memberships[0].Group.name).to.equal('Developers')
expect(user.Memberships[0].Rank.canRemove).to.equal(1)
expect(user.Memberships[1].Group.name).to.equal('Designers')
expect(user.Memberships[1].Rank.canRemove).to.equal(0)
user.products.sort(sortById)
expect(user.products.length).to.equal(2)
expect(user.products[0].tags.length).to.equal(2)
expect(user.products[1].tags.length).to.equal(1)
expect(user.products[0].category).to.be.ok
expect(user.products[1].category).not.to.be.ok
user.Products.sort(sortById)
expect(user.Products.length).to.equal(2)
expect(user.Products[0].Tags.length).to.equal(2)
expect(user.Products[1].Tags.length).to.equal(1)
expect(user.Products[0].Category).to.be.ok
expect(user.Products[1].Category).not.to.be.ok
expect(user.products[0].prices.length).to.equal(2)
expect(user.products[1].prices.length).to.equal(4)
expect(user.Products[0].Prices.length).to.equal(2)
expect(user.Products[1].Prices.length).to.equal(4)
done()
})
......@@ -435,14 +435,14 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
})
it('should support many levels of belongsTo', function (done) {
var A = this.sequelize.define('A', {}, {schema: "account"})
, B = this.sequelize.define('B', {}, {schema: "account"})
, C = this.sequelize.define('C', {}, {schema: "account"})
, D = this.sequelize.define('D', {}, {schema: "account"})
, E = this.sequelize.define('E', {}, {schema: "account"})
, F = this.sequelize.define('F', {}, {schema: "account"})
, G = this.sequelize.define('G', {}, {schema: "account"})
, H = this.sequelize.define('H', {}, {schema: "account"})
var A = this.sequelize.define('a', {}, {schema: "account"})
, B = this.sequelize.define('b', {}, {schema: "account"})
, C = this.sequelize.define('c', {}, {schema: "account"})
, D = this.sequelize.define('d', {}, {schema: "account"})
, E = this.sequelize.define('e', {}, {schema: "account"})
, F = this.sequelize.define('f', {}, {schema: "account"})
, G = this.sequelize.define('g', {}, {schema: "account"})
, H = this.sequelize.define('h', {}, {schema: "account"})
A.belongsTo(B)
B.belongsTo(C)
......@@ -484,7 +484,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
async.eachSeries(singles, function (model, callback) {
model.create({}).done(function (err, instance) {
if (previousInstance) {
previousInstance["set"+model.name](instance).done(function () {
previousInstance["set"+Sequelize.Utils.uppercaseFirst(model.name)](instance).done(function () {
previousInstance = instance
callback()
})
......@@ -602,7 +602,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
}]
}, function() {
User.findAll({
'where': {'itemA.test': 'abc'},
'where': {'itemA.test': 'abc'},
'include': [
{'model': Item, 'as': 'itemA'},
{'model': Item, 'as': 'itemB'},
......@@ -615,8 +615,8 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
expect(as[0].itemA.test).to.eql('abc')
expect(as[1].itemA.test).to.eql('abc')
expect(as[0].order.position).to.eql(1)
expect(as[1].order.position).to.eql(2)
expect(as[0].Order.position).to.eql(1)
expect(as[1].Order.position).to.eql(2)
done()
})
......@@ -686,14 +686,14 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
}).done(function (err, products) {
expect(err).not.to.be.ok
expect(products[0].tags[0].productTag.priority).to.equal(1)
expect(products[0].tags[1].productTag.priority).to.equal(2)
expect(products[0].Tags[0].ProductTag.priority).to.equal(1)
expect(products[0].Tags[1].ProductTag.priority).to.equal(2)
expect(products[1].tags[0].productTag.priority).to.equal(1)
expect(products[1].Tags[0].ProductTag.priority).to.equal(1)
expect(products[2].tags[0].productTag.priority).to.equal(3)
expect(products[2].tags[1].productTag.priority).to.equal(1)
expect(products[2].tags[2].productTag.priority).to.equal(2)
expect(products[2].Tags[0].ProductTag.priority).to.equal(3)
expect(products[2].Tags[1].ProductTag.priority).to.equal(1)
expect(products[2].Tags[2].ProductTag.priority).to.equal(2)
done()
})
......@@ -732,7 +732,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
}).done(function (err, users) {
expect(err).not.to.be.ok
expect(users.length).to.equal(1)
expect(users[0].group).to.be.ok
expect(users[0].Group).to.be.ok
done()
})
})
......@@ -778,13 +778,13 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
}).done(function (err, users) {
expect(err).not.to.be.ok
expect(users.length).to.equal(1)
expect(users[0].group).to.be.ok
expect(users[0].group.name).to.equal('A')
expect(users[0].Group).to.be.ok
expect(users[0].Group.name).to.equal('A')
done()
})
})
})
})
})
it('should be possible to extend the on clause with a where option on a belongsTo include', function (done) {
var User = this.sequelize.define('User', {}, {schema: "account"})
......@@ -825,7 +825,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
}).done(function (err, users) {
expect(err).not.to.be.ok
users.forEach(function (user) {
expect(user.group).to.be.ok
expect(user.Group).to.be.ok
})
done()
})
......@@ -893,8 +893,8 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
expect(err).not.to.be.ok
expect(users.length).to.equal(1)
users.forEach(function (user) {
expect(user.group).to.be.ok
expect(user.group.categories).to.be.ok
expect(user.Group).to.be.ok
expect(user.Group.Categories).to.be.ok
})
done()
})
......@@ -963,8 +963,8 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
expect(err).not.to.be.ok
expect(users.length).to.equal(1)
users.forEach(function (user) {
expect(user.team).to.be.ok
expect(user.team.tags).to.be.ok
expect(user.Team).to.be.ok
expect(user.Team.Tags).to.be.ok
})
done()
})
......@@ -1033,14 +1033,14 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
expect(err).not.to.be.ok
expect(users.length).to.equal(1)
users.forEach(function (user) {
expect(user.group).to.be.ok
expect(user.group.categories).to.be.ok
expect(user.Group).to.be.ok
expect(user.Group.Categories).to.be.ok
})
done()
})
})
})
})
})
it('should be possible to extend the on clause with a where option on a hasOne include', function (done) {
var User = this.sequelize.define('User', {}, {schema: "account"})
......@@ -1081,8 +1081,8 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
}).done(function (err, users) {
expect(err).not.to.be.ok
expect(users.length).to.equal(1)
expect(users[0].leaderOf).to.be.ok
expect(users[0].leaderOf.title).to.equal('Beta')
expect(users[0].LeaderOf).to.be.ok
expect(users[0].LeaderOf.title).to.equal('Beta')
done()
})
})
......@@ -1148,7 +1148,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
expect(err).not.to.be.ok
expect(products.length).to.equal(1)
expect(products[0].tags.length).to.equal(1)
expect(products[0].Tags.length).to.equal(1)
done()
})
......@@ -1320,12 +1320,12 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
]
}).done(function (err, users) {
expect(err).not.to.be.ok
users.forEach(function (user) {
expect(user.memberships.length).to.equal(1)
expect(user.memberships[0].rank.name).to.equal('Admin')
expect(user.products.length).to.equal(1)
expect(user.products[0].prices.length).to.equal(1)
expect(user.Memberships.length).to.equal(1)
expect(user.Memberships[0].Rank.name).to.equal('Admin')
expect(user.Products.length).to.equal(1)
expect(user.Products[0].Prices.length).to.equal(1)
})
done()
......@@ -1381,7 +1381,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
expect(users.length).to.equal(2)
users.forEach(function (user) {
expect(user.group.name).to.equal('A')
expect(user.Group.name).to.equal('A')
})
done()
})
......@@ -1408,9 +1408,9 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
expect(products.length).to.equal(3)
products.forEach(function (product) {
expect(product.company.name).to.equal('NYSE')
expect(product.tags.length).to.be.ok
expect(product.prices.length).to.be.ok
expect(product.Company.name).to.equal('NYSE')
expect(product.Tags.length).to.be.ok
expect(product.Prices.length).to.be.ok
})
done()
})
......@@ -1437,10 +1437,10 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
expect(products.length).to.equal(6)
products.forEach(function (product) {
expect(product.tags.length).to.be.ok
expect(product.prices.length).to.be.ok
expect(product.Tags.length).to.be.ok
expect(product.Prices.length).to.be.ok
product.prices.forEach(function (price) {
product.Prices.forEach(function (price) {
expect(price.value).to.be.above(5)
})
})
......@@ -1467,10 +1467,10 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
expect(products.length).to.equal(10)
products.forEach(function (product) {
expect(product.tags.length).to.be.ok
expect(product.prices.length).to.be.ok
expect(product.Tags.length).to.be.ok
expect(product.Prices.length).to.be.ok
product.tags.forEach(function (tag) {
product.Tags.forEach(function (tag) {
expect(['A', 'B', 'C']).to.include(tag.name)
})
})
......@@ -1497,12 +1497,12 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
User.findAll({
where: {
id: user.id
},
},
include: [Group]
}).success(function (users) {
expect(users[0].dateField.getTime()).to.equal(Date.UTC(2014, 1, 20))
expect(users[0].groups[0].dateField.getTime()).to.equal(Date.UTC(2014, 1, 20))
done()
})
})
......@@ -1511,5 +1511,5 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
})
})
})
})
\ No newline at end of file
})
})
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!