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 adfad6a8
authored
Dec 23, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'markwainwright-test-case-for-issue-2749'
2 parents
7ccfd801
2f4ed327
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
28 deletions
lib/dialects/abstract/query-generator.js
test/include/findAll.test.js
lib/dialects/abstract/query-generator.js
View file @
adfad6a
...
@@ -1112,12 +1112,20 @@ module.exports = (function() {
...
@@ -1112,12 +1112,20 @@ module.exports = (function() {
limit
:
1
limit
:
1
},
include
.
model
);
},
include
.
model
);
options
.
where
[
'__'
+
as
]
=
self
.
sequelize
.
asIs
([
var
subQueryWhere
=
self
.
sequelize
.
asIs
([
'('
,
'('
,
$query
.
replace
(
/
\;
$/
,
""
),
$query
.
replace
(
/
\;
$/
,
""
),
')'
,
')'
,
'IS NOT NULL'
'IS NOT NULL'
].
join
(
' '
));
].
join
(
' '
));
if
(
options
.
where
instanceof
Utils
.
and
)
{
options
.
where
.
args
.
push
(
subQueryWhere
);
}
else
if
(
Utils
.
_
.
isPlainObject
(
options
.
where
))
{
options
.
where
[
'__'
+
as
]
=
subQueryWhere
;
}
else
{
options
.
where
=
new
Utils
.
and
(
options
.
where
,
subQueryWhere
);
}
}
}
// Generate join SQL
// Generate join SQL
...
...
test/include/findAll.test.js
View file @
adfad6a
...
@@ -1955,16 +1955,17 @@ describe(Support.getTestDialectTeaser('Include'), function() {
...
@@ -1955,16 +1955,17 @@ describe(Support.getTestDialectTeaser('Include'), function() {
});
});
});
});
it
(
'should work with
a main record where & order and an include where
'
,
function
()
{
it
(
'should work with
paranoid, a main record where, an include where, and a limit
'
,
function
()
{
var
Post
=
this
.
sequelize
.
define
(
'post'
,
{
var
Post
=
this
.
sequelize
.
define
(
'post'
,
{
date
:
DataTypes
.
DATE
,
date
:
DataTypes
.
DATE
,
"public"
:
DataTypes
.
BOOLEAN
"public"
:
DataTypes
.
BOOLEAN
},
{
paranoid
:
true
});
});
var
Category
=
this
.
sequelize
.
define
(
'category'
,
{
var
Category
=
this
.
sequelize
.
define
(
'category'
,
{
slug
:
DataTypes
.
STRING
slug
:
DataTypes
.
STRING
});
});
Post
.
hasMany
(
Category
);
Post
.
hasMany
(
Category
);
Category
.
belongsTo
(
Post
);
Category
.
belongsTo
(
Post
);
...
@@ -1972,29 +1973,15 @@ describe(Support.getTestDialectTeaser('Include'), function() {
...
@@ -1972,29 +1973,15 @@ describe(Support.getTestDialectTeaser('Include'), function() {
return
Promise
.
join
(
return
Promise
.
join
(
Post
.
create
({
"public"
:
true
}),
Post
.
create
({
"public"
:
true
}),
Post
.
create
({
"public"
:
true
}),
Post
.
create
({
"public"
:
true
}),
Post
.
create
({
"public"
:
false
}),
Post
.
create
({
"public"
:
true
}),
Post
.
create
({
"public"
:
true
}),
Post
.
create
({
"public"
:
false
}),
Post
.
create
({
"public"
:
true
}),
Post
.
create
({
"public"
:
true
}),
Post
.
create
({
"public"
:
true
}),
Post
.
create
({
"public"
:
true
})
Post
.
create
({
"public"
:
false
}),
Post
.
create
({
"public"
:
false
})
).
then
(
function
(
posts
)
{
).
then
(
function
(
posts
)
{
return
Promise
.
join
(
return
Promise
.
map
(
posts
.
slice
(
1
,
3
),
function
(
post
)
{
Promise
.
map
(
posts
.
slice
(
4
),
function
(
post
)
{
return
post
.
createCategory
({
slug
:
'food'
});
return
post
.
createCategory
({
slug
:
'food'
});
});
}),
Promise
.
map
(
posts
.
slice
(
4
,
4
),
function
(
post
)
{
return
post
.
createCategory
({
slug
:
'yolo'
});
})
);
}).
then
(
function
()
{
}).
then
(
function
()
{
return
Post
.
findAll
({
return
Post
.
findAll
({
limit
:
3
,
limit
:
2
,
order
:
[[
'date'
,
'DESC'
]],
where
:
{
where
:
{
"public"
:
true
"public"
:
true
},
},
...
@@ -2006,16 +1993,12 @@ describe(Support.getTestDialectTeaser('Include'), function() {
...
@@ -2006,16 +1993,12 @@ describe(Support.getTestDialectTeaser('Include'), function() {
}
}
}
}
]
]
}).
on
(
'sql'
,
function
(
sql
)
{
console
.
log
(
sql
);
}).
then
(
function
(
posts
)
{
}).
then
(
function
(
posts
)
{
expect
(
posts
.
length
).
to
.
equal
(
3
);
expect
(
posts
.
length
).
to
.
equal
(
2
);
});
});
});
});
}).
catch
(
function
(
err
)
{
console
.
log
(
err
.
sql
);
throw
err
;
});
});
});
});
});
});
});
});
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