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 018a8499
authored
Feb 18, 2016
by
esteban.wagner
Committed by
Sushant
Mar 18, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(tests) Add failling test case for findAndCountAll
1 parent
00d1581f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
0 deletions
test/integration/include/findAndCountAll.test.js
test/integration/include/findAndCountAll.test.js
View file @
018a849
...
...
@@ -207,5 +207,76 @@ describe(Support.getTestDialectTeaser('Include'), function() {
expect
(
result
.
rows
.
length
).
to
.
equal
(
1
);
});
});
it
(
'should correctly filter, limit and sort when multiple includes and types of associations are present.'
,
function
()
{
var
TaskTag
=
this
.
sequelize
.
define
(
'TaskTag'
,
{
id
:
{
type
:
DataTypes
.
INTEGER
,
allowNull
:
false
,
primaryKey
:
true
,
autoIncrement
:
true
},
name
:
{
type
:
DataTypes
.
STRING
}
});
var
Tag
=
this
.
sequelize
.
define
(
'Tag'
,
{
id
:
{
type
:
DataTypes
.
INTEGER
,
allowNull
:
false
,
primaryKey
:
true
,
autoIncrement
:
true
},
name
:
{
type
:
DataTypes
.
STRING
}
});
var
Task
=
this
.
sequelize
.
define
(
'Task'
,
{
id
:
{
type
:
DataTypes
.
INTEGER
,
allowNull
:
false
,
primaryKey
:
true
,
autoIncrement
:
true
},
name
:
{
type
:
DataTypes
.
STRING
}
});
var
Project
=
this
.
sequelize
.
define
(
'Project'
,
{
id
:
{
type
:
DataTypes
.
INTEGER
,
allowNull
:
false
,
primaryKey
:
true
,
autoIncrement
:
true
},
m
:
{
type
:
DataTypes
.
STRING
}
});
var
User
=
this
.
sequelize
.
define
(
'User'
,
{
id
:
{
type
:
DataTypes
.
INTEGER
,
allowNull
:
false
,
primaryKey
:
true
,
autoIncrement
:
true
},
name
:
{
type
:
DataTypes
.
STRING
}
});
Project
.
belongsTo
(
User
);
Task
.
belongsTo
(
Project
);
Task
.
belongsToMany
(
Tag
,
{
through
:
TaskTag
});
// Sync them
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(
function
()
{
// Create an enviroment
return
Promise
.
join
(
User
.
bulkCreate
([
{
name
:
'user-name-1'
},
{
name
:
'user-name-2'
}
]),
Project
.
bulkCreate
([
{
m
:
'A'
,
UserId
:
1
},
{
m
:
'A'
,
UserId
:
2
},
]),
Task
.
bulkCreate
([
{
ProjectId
:
1
,
name
:
'Just'
},
{
ProjectId
:
1
,
name
:
'for'
},
{
ProjectId
:
2
,
name
:
'testing'
},
{
ProjectId
:
2
,
name
:
'proposes'
}
])
).
then
(
function
()
{
// Find All Tasks with Project(m=a) and User(name=user-name-2)
return
Task
.
findAndCountAll
({
limit
:
2
,
offset
:
0
,
order
:
[[
'id'
,
'ASC'
]],
include
:
[
{
model
:
Project
,
where
:
{
'$and'
:
[
{
m
:
'A'
}
]
}
,
include
:
[
{
model
:
User
,
where
:
{
'$and'
:
[
{
name
:
'user-name-2'
}
]
}
}
]
},
{
model
:
Tag
}
]
});
});
}).
then
(
function
(
result
)
{
expect
(
result
.
count
).
to
.
equal
(
2
);
expect
(
result
.
rows
.
length
).
to
.
equal
(
2
);
});
});
});
});
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