Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit d2295bc1
authored
Aug 26, 2014
by
ThePoloQ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update has-many.test.js
1 parent
b03f40bd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
test/associations/has-many.test.js
test/associations/has-many.test.js
View file @
d2295bc
...
@@ -1557,4 +1557,66 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
...
@@ -1557,4 +1557,66 @@ describe(Support.getTestDialectTeaser("HasMany"), function() {
})
})
})
})
})
})
describe
(
"issue #2145 : Test for fix ORDER BY with INNER, OUTER JOIN and LIMIT"
,
function
()
{
it
(
"can order colum and limit records with outer join"
,
function
(
done
)
{
var
Task
=
this
.
sequelize
.
define
(
'Task'
,
{
title
:
DataTypes
.
STRING
})
,
User
=
this
.
sequelize
.
define
(
'User'
,
{
username
:
DataTypes
.
STRING
})
,
Subtask
=
this
.
sequelize
.
define
(
'Subtask'
,
{
title
:
DataTypes
.
STRING
})
User
.
hasMany
(
Task
);
Task
.
belongsTo
(
User
);
Task
.
hasMany
(
Subtask
);
Subtask
.
belongsTo
(
Task
);
User
.
sync
({
force
:
true
}).
success
(
function
()
{
Task
.
sync
({
force
:
true
}).
success
(
function
()
{
Subtask
.
sync
({
force
:
true
}).
success
(
function
()
{
User
.
create
({
username
:
'myuser'
}).
success
(
function
(
myuser
)
{
var
bulkSubtasks
=
[{
title
:
'subtask1'
},{
title
:
'another subtask1'
},{
title
:
'mysubtask1'
}]
Subtask
.
bulkCreate
(
bulkSubtasks
).
success
(
function
()
{
Task
.
bulkCreate
([{
title
:
'myTask1'
},{
title
:
'ztask'
}]).
success
(
function
()
{
Task
.
create
({
title
:
'task1'
}).
success
(
function
(
task1
)
{
User
.
findAll
().
success
(
function
(
users
){
expect
(
users
).
to
.
have
.
length
(
1
);
Subtask
.
findAll
().
success
(
function
(
subtasks
){
expect
(
subtasks
).
to
.
have
.
length
(
3
);
task1
.
setSubtasks
(
subtasks
).
success
(
function
(){
Task
.
findAll
().
success
(
function
(
tasks
){
expect
(
tasks
).
to
.
have
.
length
(
3
);
myuser
.
setTasks
(
tasks
).
success
(
function
(){
Task
.
findAll
({
include
:
[
{
model
:
User
,
attributes
:
[
'username'
],
required
:
true
},
{
model
:
Subtask
,
attributes
:
[
'title'
]},
],
order
:
[
[
Sequelize
.
col
(
'Tasks.title'
)],
[
Sequelize
.
col
(
'Subtasks.title'
)],
],
limit
:
2
}).
success
(
function
(
ftasks
){
expect
(
ftasks
).
to
.
have
.
length
(
2
);
var
count
=
0
;
ftasks
.
forEach
(
function
(
task
){
count
+=
task
.
subtasks
.
length
;
});
expect
(
count
).
to
.
equal
(
3
);
done
();
})
});
});
});
});
});
});
})
})
})
})
})
})
})
})
})
})
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment