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 58a0314a
authored
Jan 14, 2015
by
Erik van de Ven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
write test "should be possible to select on columns inside a through table"
1 parent
96d54225
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
17 deletions
test/include/findAll.test.js
test/include/findAll.test.js
View file @
58a0314
...
@@ -1750,6 +1750,32 @@ describe(Support.getTestDialectTeaser('Include'), function() {
...
@@ -1750,6 +1750,32 @@ describe(Support.getTestDialectTeaser('Include'), function() {
});
});
});
});
it
(
'should be possible to select on columns inside a through table'
,
function
(
done
)
{
var
self
=
this
;
this
.
fixtureA
(
function
()
{
self
.
models
.
Product
.
findAll
({
attributes
:
[
'title'
],
include
:
[
{
model
:
self
.
models
.
Tag
,
through
:
{
where
:
{
ProductId
:
3
}
},
required
:
true
}
]
}).
done
(
function
(
err
,
products
)
{
expect
(
err
).
not
.
to
.
be
.
ok
;
expect
(
products
).
have
.
length
(
1
);
done
();
});
});
});
// Test case by @eshell
// Test case by @eshell
it
(
'should be possible not to include the main id in the attributes'
,
function
(
done
)
{
it
(
'should be possible not to include the main id in the attributes'
,
function
(
done
)
{
var
Member
=
this
.
sequelize
.
define
(
'Member'
,
{
var
Member
=
this
.
sequelize
.
define
(
'Member'
,
{
...
@@ -1999,18 +2025,18 @@ describe(Support.getTestDialectTeaser('Include'), function() {
...
@@ -1999,18 +2025,18 @@ describe(Support.getTestDialectTeaser('Include'), function() {
});
});
});
});
});
});
it
(
'should work on a nested set of required 1:1 relations'
,
function
()
{
it
(
'should work on a nested set of required 1:1 relations'
,
function
()
{
var
Person
=
this
.
sequelize
.
define
(
"Person"
,
{
var
Person
=
this
.
sequelize
.
define
(
"Person"
,
{
name
:
{
name
:
{
type
:
Sequelize
.
STRING
,
type
:
Sequelize
.
STRING
,
allowNull
:
false
allowNull
:
false
}
}
});
});
var
UserPerson
=
this
.
sequelize
.
define
(
"UserPerson"
,
{
var
UserPerson
=
this
.
sequelize
.
define
(
"UserPerson"
,
{
PersonId
:
{
PersonId
:
{
type
:
Sequelize
.
INTEGER
,
type
:
Sequelize
.
INTEGER
,
primaryKey
:
true
primaryKey
:
true
},
},
...
@@ -2020,8 +2046,8 @@ describe(Support.getTestDialectTeaser('Include'), function() {
...
@@ -2020,8 +2046,8 @@ describe(Support.getTestDialectTeaser('Include'), function() {
});
});
var
User
=
this
.
sequelize
.
define
(
"User"
,
{
var
User
=
this
.
sequelize
.
define
(
"User"
,
{
UserPersonId
:
{
UserPersonId
:
{
type
:
Sequelize
.
INTEGER
,
type
:
Sequelize
.
INTEGER
,
primaryKey
:
true
primaryKey
:
true
},
},
...
@@ -2032,20 +2058,20 @@ describe(Support.getTestDialectTeaser('Include'), function() {
...
@@ -2032,20 +2058,20 @@ describe(Support.getTestDialectTeaser('Include'), function() {
}
}
});
});
UserPerson
.
belongsTo
(
Person
,
{
UserPerson
.
belongsTo
(
Person
,
{
foreignKey
:
{
foreignKey
:
{
allowNull
:
false
allowNull
:
false
},
},
onDelete
:
'CASCADE'
onDelete
:
'CASCADE'
});
});
Person
.
hasOne
(
UserPerson
,
{
Person
.
hasOne
(
UserPerson
,
{
foreignKey
:
{
foreignKey
:
{
allowNull
:
false
allowNull
:
false
},
},
onDelete
:
'CASCADE'
onDelete
:
'CASCADE'
});
});
User
.
belongsTo
(
UserPerson
,
{
User
.
belongsTo
(
UserPerson
,
{
foreignKey
:
{
foreignKey
:
{
name
:
'UserPersonId'
,
name
:
'UserPersonId'
,
allowNull
:
false
allowNull
:
false
...
@@ -2053,7 +2079,7 @@ describe(Support.getTestDialectTeaser('Include'), function() {
...
@@ -2053,7 +2079,7 @@ describe(Support.getTestDialectTeaser('Include'), function() {
onDelete
:
'CASCADE'
onDelete
:
'CASCADE'
});
});
UserPerson
.
hasOne
(
User
,
{
UserPerson
.
hasOne
(
User
,
{
foreignKey
:
{
foreignKey
:
{
name
:
'UserPersonId'
,
name
:
'UserPersonId'
,
allowNull
:
false
allowNull
:
false
},
},
...
@@ -2063,12 +2089,12 @@ describe(Support.getTestDialectTeaser('Include'), function() {
...
@@ -2063,12 +2089,12 @@ describe(Support.getTestDialectTeaser('Include'), function() {
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(
function
()
{
return
this
.
sequelize
.
sync
({
force
:
true
}).
then
(
function
()
{
return
Person
.
findAll
({
return
Person
.
findAll
({
offset
:
0
,
offset
:
0
,
limit
:
20
,
limit
:
20
,
attributes
:
[
'id'
,
'name'
],
attributes
:
[
'id'
,
'name'
],
include
:
[{
include
:
[{
model
:
UserPerson
,
model
:
UserPerson
,
required
:
true
,
required
:
true
,
attributes
:
[
'rank'
],
attributes
:
[
'rank'
],
include
:
[{
include
:
[{
model
:
User
,
model
:
User
,
required
:
true
,
required
:
true
,
...
...
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