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

Commit 6e13407a by Matt Broadstone

unify selectQuery between abstract and mssql dialects

1 parent d1b914f7
...@@ -1083,7 +1083,9 @@ module.exports = (function() { ...@@ -1083,7 +1083,9 @@ module.exports = (function() {
} else { } else {
if (association.associationType !== 'BelongsTo') { if (association.associationType !== 'BelongsTo') {
// Alias the left attribute if the left attribute is not from a subqueried main table // Alias the left attribute if the left attribute is not from a subqueried main table
// When doing a query like SELECT aliasedKey FROM (SELECT primaryKey FROM primaryTable) only aliasedKey is available to the join, this is not the case when doing a regular select where you can't used the aliased attribute // When doing a query like SELECT aliasedKey FROM (SELECT primaryKey FROM primaryTable)
// only aliasedKey is available to the join, this is not the case when doing a regular
// select where you can't used the aliased attribute
if (!subQuery || (subQuery && !include.subQuery && include.parent.model !== mainModel)) { if (!subQuery || (subQuery && !include.subQuery && include.parent.model !== mainModel)) {
if (left.rawAttributes[attrLeft].field) { if (left.rawAttributes[attrLeft].field) {
attrLeft = left.rawAttributes[attrLeft].field; attrLeft = left.rawAttributes[attrLeft].field;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
var chai = require('chai') var chai = require('chai')
, Sequelize = require('../../index') , Sequelize = require('../../index')
, expect = chai.expect , expect = chai.expect
, Support = require(__dirname + '/../support') , Support = require(__dirname + '/../support')
, dialect = Support.getTestDialect() , dialect = Support.getTestDialect()
, DataTypes = require(__dirname + "/../../lib/data-types") , DataTypes = require(__dirname + "/../../lib/data-types")
, datetime = require('chai-datetime') , datetime = require('chai-datetime')
...@@ -229,7 +229,7 @@ describe(Support.getTestDialectTeaser("Include"), function () { ...@@ -229,7 +229,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
}, callback) }, callback)
}, },
function (err) { function (err) {
console.log('err', err); // console.log('err', err);
expect(err).not.to.be.ok expect(err).not.to.be.ok
done() done()
} }
...@@ -256,14 +256,14 @@ describe(Support.getTestDialectTeaser("Include"), function () { ...@@ -256,14 +256,14 @@ describe(Support.getTestDialectTeaser("Include"), function () {
SubscriptionForm.belongsTo(Category, {foreignKey:'boundCategory'}); SubscriptionForm.belongsTo(Category, {foreignKey:'boundCategory'});
Category.hasMany(SubscriptionForm, {foreignKey:'boundCategory'}); Category.hasMany(SubscriptionForm, {foreignKey:'boundCategory'});
Capital.hasMany(Category, { foreignKey: 'boundCapital'}); Capital.hasMany(Category, { foreignKey: 'boundCapital'});
Category.belongsTo(Capital, {foreignKey:'boundCapital'}); Category.belongsTo(Capital, {foreignKey:'boundCapital'});
Category.hasMany(SubCategory, {foreignKey:'boundCategory'}); Category.hasMany(SubCategory, {foreignKey:'boundCategory'});
SubCategory.belongsTo(Category, {foreignKey: 'boundCategory'}); SubCategory.belongsTo(Category, {foreignKey: 'boundCategory'});
return this.sequelize.sync({force: true}).then(function() { return this.sequelize.sync({force: true}).then(function() {
return User.find({ return User.find({
include: [ include: [
...@@ -1162,7 +1162,7 @@ describe(Support.getTestDialectTeaser("Include"), function () { ...@@ -1162,7 +1162,7 @@ describe(Support.getTestDialectTeaser("Include"), function () {
chainer.run().done(callback) chainer.run().done(callback)
}] }]
}, function (err) { }, function (err) {
expect(err).not.to.be.ok expect(err).not.to.be.ok
User.findAll({ User.findAll({
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!