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

Commit 95d3a571 by Jan Aagaard Meier

add: groupedLimit.through.where

1 parent c2d20343
......@@ -2,6 +2,8 @@
- [FIXED] Issues with `createFunction` and `dropFunction` (PostgresSQL)
- [FIXED] Issue with belongsTo association and foreign keys [#6400](https://github.com/sequelize/sequelize/issues/6400)
- [FIXED] Issue with query generation in MSSQL, an identifier was not escaped [#6686] (https://github.com/sequelize/sequelize/pull/6686)
- [FIXED] GroupedLimit when foreignKey has a field alias
- [FIXED] groupedLimit.through.where support
# 4.0.0-2
- [ADDED] include now supports string as an argument (on top of model/association), string will expand into an association matched literally from Model.associations
......
......@@ -852,9 +852,9 @@ const QueryGenerator = {
association: options.groupedLimit.on.manyFromSource,
duplicating: false, // The UNION'ed query may contain duplicates, but each sub-query cannot
required: true,
where: {
where: Object.assign({
'$$PLACEHOLDER$$': true
}
}, options.groupedLimit.through && options.groupedLimit.through.where)
}],
model
});
......
......@@ -133,6 +133,38 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
['id_user', 'id']
],
order: [
['last_name', 'ASC']
],
groupedLimit: {
limit: 3,
through: {
where: {
status: 1
}
},
on: User.Projects,
values: [
1,
5
]
}
}, {
default: 'SELECT [user].* FROM ('+
[
'(SELECT [user].[id_user] AS [id], [user].[last_name] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 1 AND [project_users].[status] = 1 ORDER BY [subquery_order_0] ASC'+ (current.dialect.name === 'mssql' ? ', [id_user]' : '') + sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })+')',
'(SELECT [user].[id_user] AS [id], [user].[last_name] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 5 AND [project_users].[status] = 1 ORDER BY [subquery_order_0] ASC'+ (current.dialect.name === 'mssql' ? ', [id_user]' : '') +sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })+')'
].join(current.dialect.supports['UNION ALL'] ?' UNION ALL ' : ' UNION ')
+') AS [user] ORDER BY [subquery_order_0] ASC;'
});
testsql({
table: User.getTableName(),
model: User,
attributes: [
['id_user', 'id']
],
order: [
['id_user', 'ASC']
],
where: {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!