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 6486f3c3
authored
Apr 01, 2016
by
Mick Hansen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5632 from philip1986/fix-limit=0
fix limit=0 issue
2 parents
f8f732ea
e8a46cd1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
8 deletions
.jshintrc
lib/dialects/abstract/query-generator.js
lib/dialects/postgres/query-generator.js
test/unit/dialects/mysql/query-generator.test.js
test/unit/dialects/postgres/query-generator.test.js
.jshintrc
View file @
6486f3c
...
@@ -17,7 +17,8 @@
...
@@ -17,7 +17,8 @@
"nonbsp": true,
"nonbsp": true,
"maxdepth": 8,
"maxdepth": 8,
"quotmark": true, // deprecated
"quotmark": true, // deprecated
"-W041": false,
/* relaxing options */
/* relaxing options */
"laxbreak":true,
"laxbreak":true,
"laxcomma":true,
"laxcomma":true,
...
@@ -44,4 +45,4 @@
...
@@ -44,4 +45,4 @@
"suiteTeardown",
"suiteTeardown",
"test"
"test"
]
]
}
}
\ No newline at end of file
lib/dialects/abstract/query-generator.js
View file @
6486f3c
...
@@ -1756,10 +1756,12 @@ var QueryGenerator = {
...
@@ -1756,10 +1756,12 @@ var QueryGenerator = {
*/
*/
addLimitAndOffset
:
function
(
options
,
model
)
{
addLimitAndOffset
:
function
(
options
,
model
)
{
var
fragment
=
''
;
var
fragment
=
''
;
if
(
options
.
offset
&&
!
options
.
limit
)
{
/*jshint eqeqeq:false*/
if
(
options
.
offset
!=
null
&&
options
.
limit
==
null
)
{
fragment
+=
' LIMIT '
+
this
.
escape
(
options
.
offset
)
+
', '
+
10000000000000
;
fragment
+=
' LIMIT '
+
this
.
escape
(
options
.
offset
)
+
', '
+
10000000000000
;
}
else
if
(
options
.
limit
)
{
}
else
if
(
options
.
limit
!=
null
)
{
if
(
options
.
offset
)
{
if
(
options
.
offset
!=
null
)
{
fragment
+=
' LIMIT '
+
this
.
escape
(
options
.
offset
)
+
', '
+
this
.
escape
(
options
.
limit
);
fragment
+=
' LIMIT '
+
this
.
escape
(
options
.
offset
)
+
', '
+
this
.
escape
(
options
.
limit
);
}
else
{
}
else
{
fragment
+=
' LIMIT '
+
this
.
escape
(
options
.
limit
);
fragment
+=
' LIMIT '
+
this
.
escape
(
options
.
limit
);
...
...
lib/dialects/postgres/query-generator.js
View file @
6486f3c
...
@@ -417,8 +417,13 @@ var QueryGenerator = {
...
@@ -417,8 +417,13 @@ var QueryGenerator = {
addLimitAndOffset
:
function
(
options
)
{
addLimitAndOffset
:
function
(
options
)
{
var
fragment
=
''
;
var
fragment
=
''
;
if
(
options
.
limit
)
fragment
+=
' LIMIT '
+
this
.
escape
(
options
.
limit
);
/*jshint eqeqeq:false*/
if
(
options
.
offset
)
fragment
+=
' OFFSET '
+
this
.
escape
(
options
.
offset
);
if
(
options
.
limit
!=
null
)
{
fragment
+=
' LIMIT '
+
this
.
escape
(
options
.
limit
);
}
if
(
options
.
offset
!=
null
)
{
fragment
+=
' OFFSET '
+
this
.
escape
(
options
.
offset
);
}
return
fragment
;
return
fragment
;
},
},
...
...
test/unit/dialects/mysql/query-generator.test.js
View file @
6486f3c
...
@@ -335,6 +335,16 @@ if (Support.dialectIsMySQL()) {
...
@@ -335,6 +335,16 @@ if (Support.dialectIsMySQL()) {
expectation
:
'SELECT * FROM `myTable` LIMIT 2, 10000000000000;'
,
expectation
:
'SELECT * FROM `myTable` LIMIT 2, 10000000000000;'
,
context
:
QueryGenerator
context
:
QueryGenerator
},
{
},
{
title
:
'uses limit 0'
,
arguments
:
[
'myTable'
,
{
limit
:
0
}],
expectation
:
'SELECT * FROM `myTable` LIMIT 0;'
,
context
:
QueryGenerator
},
{
title
:
'uses offset 0'
,
arguments
:
[
'myTable'
,
{
offset
:
0
}],
expectation
:
'SELECT * FROM `myTable` LIMIT 0, 10000000000000;'
,
context
:
QueryGenerator
},
{
title
:
'multiple where arguments'
,
title
:
'multiple where arguments'
,
arguments
:
[
'myTable'
,
{
where
:
{
boat
:
'canoe'
,
weather
:
'cold'
}}],
arguments
:
[
'myTable'
,
{
where
:
{
boat
:
'canoe'
,
weather
:
'cold'
}}],
expectation
:
"SELECT * FROM `myTable` WHERE `myTable`.`boat` = 'canoe' AND `myTable`.`weather` = 'cold';"
,
expectation
:
"SELECT * FROM `myTable` WHERE `myTable`.`boat` = 'canoe' AND `myTable`.`weather` = 'cold';"
,
...
...
test/unit/dialects/postgres/query-generator.test.js
View file @
6486f3c
...
@@ -291,7 +291,17 @@ if (dialect.match(/^postgres/)) {
...
@@ -291,7 +291,17 @@ if (dialect.match(/^postgres/)) {
expectation
:
'SELECT * FROM "myTable" AS "myTable" ORDER BY "myTable"."id" DESC;'
,
expectation
:
'SELECT * FROM "myTable" AS "myTable" ORDER BY "myTable"."id" DESC;'
,
context
:
QueryGenerator
,
context
:
QueryGenerator
,
needsSequelize
:
true
needsSequelize
:
true
},{
title
:
'uses limit 0'
,
arguments
:
[
'myTable'
,
{
limit
:
0
}],
expectation
:
'SELECT * FROM "myTable" LIMIT 0;'
,
context
:
QueryGenerator
},
{
},
{
title
:
'uses offset 0'
,
arguments
:
[
'myTable'
,
{
offset
:
0
}],
expectation
:
'SELECT * FROM "myTable" OFFSET 0;'
,
context
:
QueryGenerator
},
{
title
:
'raw arguments are neither quoted nor escaped'
,
title
:
'raw arguments are neither quoted nor escaped'
,
arguments
:
[
'myTable'
,
{
order
:
[[{
raw
:
'f1(f2(id))'
},
'DESC'
]]}],
arguments
:
[
'myTable'
,
{
order
:
[[{
raw
:
'f1(f2(id))'
},
'DESC'
]]}],
expectation
:
'SELECT * FROM "myTable" ORDER BY f1(f2(id)) DESC;'
,
expectation
:
'SELECT * FROM "myTable" ORDER BY f1(f2(id)) DESC;'
,
...
...
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