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 182caa98
authored
Jun 24, 2013
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Closes #723
1 parent
3c14f562
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
8 deletions
lib/dialects/mysql/query-generator.js
lib/dialects/sqlite/query-generator.js
spec-jasmine/dao-factory.spec.js
lib/dialects/mysql/query-generator.js
View file @
182caa9
...
@@ -217,8 +217,14 @@ module.exports = (function() {
...
@@ -217,8 +217,14 @@ module.exports = (function() {
query
+=
" ORDER BY "
+
options
.
order
query
+=
" ORDER BY "
+
options
.
order
}
}
if
(
options
.
offset
&&
!
options
.
limit
)
{
if
(
options
.
limit
&&
!
(
options
.
include
&&
(
options
.
limit
===
1
)))
{
/*
* If not limit is defined, our best bet is to use the max number of rows in a table. From the MySQL docs:
* There is a limit of 2^32 (~4.295E+09) rows in a MyISAM table. If you build MySQL with the --with-big-tables option,
* the row limitation is increased to (2^32)^2 (1.844E+19) rows.
*/
query
+=
" LIMIT "
+
options
.
offset
+
", "
+
18440000000000000000
;
}
else
if
(
options
.
limit
&&
!
(
options
.
include
&&
(
options
.
limit
===
1
)))
{
if
(
options
.
offset
)
{
if
(
options
.
offset
)
{
query
+=
" LIMIT "
+
options
.
offset
+
", "
+
options
.
limit
query
+=
" LIMIT "
+
options
.
offset
+
", "
+
options
.
limit
}
else
{
}
else
{
...
...
lib/dialects/sqlite/query-generator.js
View file @
182caa9
...
@@ -188,8 +188,13 @@ module.exports = (function() {
...
@@ -188,8 +188,13 @@ module.exports = (function() {
query
+=
" ORDER BY "
+
options
.
order
query
+=
" ORDER BY "
+
options
.
order
}
}
if
(
options
.
offset
&&
!
options
.
limit
)
{
if
(
options
.
limit
&&
!
(
options
.
include
&&
(
options
.
limit
===
1
)))
{
/*
* If not limit is defined, our best bet is to use the max number of rows in a table. From the SQLite docs:
* A 140 terabytes database can hold no more than approximately 1e+13 rows
*/
query
+=
" LIMIT "
+
options
.
offset
+
", "
+
10000000000000
;
}
else
if
(
options
.
limit
&&
!
(
options
.
include
&&
(
options
.
limit
===
1
)))
{
if
(
options
.
offset
)
{
if
(
options
.
offset
)
{
query
+=
" LIMIT "
+
options
.
offset
+
", "
+
options
.
limit
query
+=
" LIMIT "
+
options
.
offset
+
", "
+
options
.
limit
}
else
{
}
else
{
...
...
spec-jasmine/dao-factory.spec.js
View file @
182caa9
...
@@ -238,9 +238,7 @@ describe('DAOFactory', function() {
...
@@ -238,9 +238,7 @@ describe('DAOFactory', function() {
})
})
})
})
})
})
/*
// at time of writing (v1.6.0) Sequelize does not seem to support 'offset' on it's own consistently (goes wrong for PostGRES and SQLite)
it
(
"handles offset"
,
function
()
{
it
(
"handles offset"
,
function
()
{
Helpers
.
async
(
function
(
done
)
{
Helpers
.
async
(
function
(
done
)
{
User
.
findAndCountAll
({
offset
:
1
}).
success
(
function
(
info
)
{
User
.
findAndCountAll
({
offset
:
1
}).
success
(
function
(
info
)
{
...
@@ -251,7 +249,7 @@ describe('DAOFactory', function() {
...
@@ -251,7 +249,7 @@ describe('DAOFactory', function() {
})
})
})
})
})
})
*/
it
(
"handles limit"
,
function
()
{
it
(
"handles limit"
,
function
()
{
Helpers
.
async
(
function
(
done
)
{
Helpers
.
async
(
function
(
done
)
{
User
.
findAndCountAll
({
limit
:
1
}).
success
(
function
(
info
)
{
User
.
findAndCountAll
({
limit
:
1
}).
success
(
function
(
info
)
{
...
...
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