Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offset ignored when no limit is specified #88

Closed
Torgan opened this issue Apr 11, 2016 · 2 comments
Closed

Offset ignored when no limit is specified #88

Torgan opened this issue Apr 11, 2016 · 2 comments
Labels

Comments

@Torgan
Copy link

Torgan commented Apr 11, 2016

Hello,

It looks like that the select query builder ignore the offset value if no limit is provided, which it shouldn't :

$queryBuilder
    ->cols('id')
    ->from('user')
    ->orderBy([ 'id' ])
    ->offset(5);

gives the following statement :

SELECT id FROM "user" ORDER BY id

According to SQL specification, it should work just fine (it does with postgreSQL) :

SELECT id FROM "user" ORDER BY id OFFSET 5

With mySQL, as explained in the documentation (http://dev.mysql.com/doc/refman/5.7/en/select.html), it should be handled this way :

To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter. This statement retrieves all rows from the 96th row to the last:

SELECT * FROM tbl LIMIT 95,18446744073709551615;
@harikt
Copy link
Member

harikt commented Apr 11, 2016

Thank you @Torgan for the report. Probably we need to override

protected function buildLimit()
for postrgres.

@Torgan
Copy link
Author

Torgan commented Apr 11, 2016

Yes, looks like it's the way to go. Could be done for mySQL also I guess.

@harikt harikt added the bug label Apr 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants