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

Commit cbabc1c8 by Mick Hansen

get schema tests working

1 parent 356cd4fe
...@@ -34,7 +34,7 @@ module.exports = (function() { ...@@ -34,7 +34,7 @@ module.exports = (function() {
new Utils.where( new Utils.where(
through.rawAttributes[self.association.foreignIdentifier], { through.rawAttributes[self.association.foreignIdentifier], {
join: new Utils.literal([ join: new Utils.literal([
self.QueryInterface.quoteTable(self.association.target.getTableName()), self.QueryInterface.quoteTable(self.association.target.name),
self.QueryInterface.quoteIdentifier(foreignPrimaryKey) self.QueryInterface.quoteIdentifier(foreignPrimaryKey)
].join('.')) ].join('.'))
} }
......
...@@ -67,7 +67,7 @@ module.exports = (function() { ...@@ -67,7 +67,7 @@ module.exports = (function() {
var where = {} var where = {}
params = params || {} params = params || {}
params.where = [params.where] || [] params.where = (params.where && [params.where]) || []
where[association.identifier] = this.get(association.sourceIdentifier) where[association.identifier] = this.get(association.sourceIdentifier)
params.where.push(where) params.where.push(where)
......
...@@ -648,7 +648,7 @@ module.exports = (function() { ...@@ -648,7 +648,7 @@ module.exports = (function() {
if (subQuery) { if (subQuery) {
// We need primary keys // We need primary keys
subQueryAttributes = mainAttributes subQueryAttributes = mainAttributes
mainAttributes = mainTableAs[mainTableAs+'.*'] mainAttributes = [mainTableAs+'.*']
} }
if (options.include) { if (options.include) {
...@@ -816,13 +816,16 @@ module.exports = (function() { ...@@ -816,13 +816,16 @@ module.exports = (function() {
// If using subQuery select defined subQuery attributes and join subJoinQueries // If using subQuery select defined subQuery attributes and join subJoinQueries
if (subQuery) { if (subQuery) {
subQueryItems.push("SELECT " + subQueryAttributes.join(', ') + " FROM " + options.table) subQueryItems.push("SELECT " + subQueryAttributes.join(', ') + " FROM " + options.table)
if (mainTableAs) {
subQueryItems.push(" AS "+mainTableAs)
}
subQueryItems.push(subJoinQueries.join('')) subQueryItems.push(subJoinQueries.join(''))
// Else do it the reguar way // Else do it the reguar way
} else { } else {
mainQueryItems.push("SELECT " + mainAttributes.join(', ') + " FROM " + options.table) mainQueryItems.push("SELECT " + mainAttributes.join(', ') + " FROM " + options.table)
if (options.tableAs) { if (mainTableAs) {
mainQueryItems.push(" AS "+options.tableAs) mainQueryItems.push(" AS "+mainTableAs)
} }
mainQueryItems.push(mainJoinQueries.join('')) mainQueryItems.push(mainJoinQueries.join(''))
} }
...@@ -830,7 +833,7 @@ module.exports = (function() { ...@@ -830,7 +833,7 @@ module.exports = (function() {
// Add WHERE to sub or main query // Add WHERE to sub or main query
if (options.hasOwnProperty('where')) { if (options.hasOwnProperty('where')) {
options.where = this.getWhereConditions(options.where, tableName, Model, options) options.where = this.getWhereConditions(options.where, mainTableAs, Model, options)
if (subQuery) { if (subQuery) {
subQueryItems.push(" WHERE " + options.where) subQueryItems.push(" WHERE " + options.where)
} else { } else {
......
...@@ -245,7 +245,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () { ...@@ -245,7 +245,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
} }
}) })
it.only('should support an include with multiple different association types', function (done) { it('should support an include with multiple different association types', function (done) {
var self = this var self = this
self.sequelize.dropAllSchemas().success(function(){ self.sequelize.dropAllSchemas().success(function(){
...@@ -388,8 +388,6 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () { ...@@ -388,8 +388,6 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
}, callback) }, callback)
}, },
function (err) { function (err) {
console.log(err.sql);
console.log(err);
expect(err).not.to.be.ok expect(err).not.to.be.ok
AccUser.findAll({ AccUser.findAll({
...@@ -436,8 +434,6 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () { ...@@ -436,8 +434,6 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
) )
}] }]
}, done) }, done)
}).error(done).on('sql', function (sql) {
console.log(sql)
}) })
}) })
}) })
...@@ -1052,7 +1048,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () { ...@@ -1052,7 +1048,7 @@ describe(Support.getTestDialectTeaser("Includes with schemas"), function () {
}) })
}) })
it('should be possible to extend the on clause with a where option on a hasOne include', function (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"}) var User = this.sequelize.define('User', {}, {schema: "account"})
, Project = this.sequelize.define('Project', { , Project = this.sequelize.define('Project', {
title: DataTypes.STRING title: DataTypes.STRING
...@@ -1409,7 +1405,7 @@ it('should be possible to extend the on clause with a where option on a hasOne i ...@@ -1409,7 +1405,7 @@ it('should be possible to extend the on clause with a where option on a hasOne i
], ],
limit: 3, limit: 3,
order: [ order: [
[self.sequelize.literal(self.models.Product.getTableName()+'.id'), 'ASC'] [self.models.Product.name+'.id', 'ASC']
] ]
}).done(function (err, products) { }).done(function (err, products) {
expect(err).not.to.be.ok expect(err).not.to.be.ok
...@@ -1484,7 +1480,7 @@ it('should be possible to extend the on clause with a where option on a hasOne i ...@@ -1484,7 +1480,7 @@ it('should be possible to extend the on clause with a where option on a hasOne i
}) })
}) })
it('should support including date fields, with the correct timeszone', function (done) { xit('should support including date fields, with the correct timeszone', function (done) {
var User = this.sequelize.define('user', { var User = this.sequelize.define('user', {
dateField: Sequelize.DATE dateField: Sequelize.DATE
}, {timestamps: false, schema: "account"}) }, {timestamps: false, schema: "account"})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!