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

Commit b6a2c61f by Mick Hansen

remove dao.instanceValues

1 parent 6f2072ae
...@@ -12,8 +12,6 @@ module.exports = (function() { ...@@ -12,8 +12,6 @@ module.exports = (function() {
this.__options = this.Model.options this.__options = this.Model.options
this.options = options this.options = options
this.hasPrimaryKeys = this.Model.options.hasPrimaryKeys this.hasPrimaryKeys = this.Model.options.hasPrimaryKeys
// What is selected values even used for?
this.selectedValues = options.include ? _.omit(values, options.includeNames) : values
this.__eagerlyLoadedAssociations = [] this.__eagerlyLoadedAssociations = []
this.isNewRecord = options.isNewRecord this.isNewRecord = options.isNewRecord
......
...@@ -347,12 +347,6 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -347,12 +347,6 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
done() done()
}) })
it("stores the passed values in a special variable", function(done) {
var user = this.User.build({ username: 'John Wayne' })
expect(user.selectedValues).to.deep.equal({ username: 'John Wayne' })
done()
})
it("attaches getter and setter methods from attribute definition", function(done) { it("attaches getter and setter methods from attribute definition", function(done) {
var Product = this.sequelize.define('ProductWithSettersAndGetters1', { var Product = this.sequelize.define('ProductWithSettersAndGetters1', {
price: { price: {
......
...@@ -228,82 +228,6 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -228,82 +228,6 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
}) })
it('returns the selected fields as instance.selectedValues', function(done) {
var self = this
this.User.create({
username: 'JohnXOXOXO'
}).success(function() {
self.User.find({
where: { username: 'JohnXOXOXO' },
attributes: ['username']
}).done(function(err, user) {
expect(err).not.to.be.ok
expect(_.omit(user.selectedValues, ['id'])).to.have.property('username', 'JohnXOXOXO')
done()
})
})
})
it('returns the selected fields and all fields of the included table as instance.selectedValues', function(done) {
var self = this
self.Mission = self.sequelize.define('Mission', {
title: {type: Sequelize.STRING, defaultValue: 'a mission!!'},
foo: {type: Sequelize.INTEGER, defaultValue: 2},
})
self.Mission.belongsTo(self.User)
self.User.hasMany(self.Mission)
self.Mission.sync({ force: true }).success(function() {
self.Mission.create().success(function(mission) {
self.User.create({username: 'John DOE'}).success(function(user) {
mission.setUser(user).success(function() {
self.User.find({
where: { username: 'John DOE' },
attributes: ['username'],
include: [self.Mission]
}).done(function(err, user) {
expect(err).not.to.be.ok
expect(_.omit(user.selectedValues, ['id'])).to.deep.equal({ username: 'John DOE' })
done()
})
})
})
})
})
})
it('returns the selected fields for both the base table and the included table as instance.selectedValues', function(done) {
var self = this
self.Mission = self.sequelize.define('Mission', {
title: {type: Sequelize.STRING, defaultValue: 'another mission!!'},
foo: {type: Sequelize.INTEGER, defaultValue: 4},
})
self.Mission.belongsTo(self.User)
self.User.hasMany(self.Mission)
self.Mission.sync({ force: true }).success(function() {
self.Mission.create().success(function(mission) {
self.User.create({username: 'Brain Picker'}).success(function(user) {
mission.setUser(user).success(function() {
self.User.find({
where: { username: 'Brain Picker' },
attributes: ['username'],
include: [{model: self.Mission, as: self.Mission.tableName, attributes: ['title']}]
}).success(function(user) {
expect(_.omit(user.selectedValues, ['id'])).to.deep.equal({ username: 'Brain Picker' })
expect(user.missions[0].selectedValues).to.deep.equal({ id: 1, title: 'another mission!!'})
expect(user.missions[0].foo).not.to.exist
done()
})
})
})
})
})
})
it('always honors ZERO as primary key', function(_done) { it('always honors ZERO as primary key', function(_done) {
var self = this var self = this
, permutations = [ , permutations = [
......
...@@ -1464,8 +1464,8 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1464,8 +1464,8 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
expect(info.count).to.equal(2) expect(info.count).to.equal(2)
expect(Array.isArray(info.rows)).to.be.ok expect(Array.isArray(info.rows)).to.be.ok
expect(info.rows.length).to.equal(2) expect(info.rows.length).to.equal(2)
expect(info.rows[0].selectedValues).to.not.have.property('username') expect(info.rows[0].dataValues).to.not.have.property('username')
expect(info.rows[1].selectedValues).to.not.have.property('username') expect(info.rows[1].dataValues).to.not.have.property('username')
done() done()
}) })
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!