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

Commit 76ec38c3 by Matt Broadstone

fix broken sql for Sequelize.literal include test

1 parent 106204fa
Showing with 16 additions and 5 deletions
......@@ -9,6 +9,7 @@ var chai = require('chai')
, datetime = require('chai-datetime')
, async = require('async')
, _ = require('lodash')
, dialect = Support.getTestDialect();
chai.use(datetime)
chai.config.includeStack = true
......@@ -619,15 +620,25 @@ describe(Support.getTestDialectTeaser("Include"), function () {
comment_title: 'WAT'
});
}).then(function () {
var findAttributes;
if (dialect === 'mssql') {
findAttributes = [
Sequelize.literal('CAST(CASE WHEN EXISTS(SELECT 1) THEN 1 ELSE 0 END AS BIT) AS "PostComments.someProperty"'),
[Sequelize.literal('CAST(CASE WHEN EXISTS(SELECT 1) THEN 1 ELSE 0 END AS BIT)'), 'someProperty2']
];
} else {
findAttributes = [
Sequelize.literal('EXISTS(SELECT 1) AS "PostComments.someProperty"'),
[Sequelize.literal('EXISTS(SELECT 1)'), 'someProperty2']
];
}
findAttributes.push(['comment_title', 'commentTitle']);
return Post.findAll({
include: [
{
model: PostComment,
attributes: [
Sequelize.literal('EXISTS(SELECT 1) AS "PostComments.someProperty"'),
[Sequelize.literal('EXISTS(SELECT 1)'), 'someProperty2'],
['comment_title', 'commentTitle']
]
attributes: findAttributes
}
]
})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!