Skip to content

Commit

Permalink
Merge pull request #782 from Ocramius/hotfix/sqlite-offset-with-no-li…
Browse files Browse the repository at this point in the history
…mit-support

Fix: SQLite offset with no limit support
  • Loading branch information
Ocramius committed Jan 24, 2015
2 parents 170817a + 74f2bee commit 2a9dd3c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,18 @@ protected function getPostAlterTableIndexForeignKeySQL(TableDiff $diff)
return $sql;
}

/**
* {@inheritDoc}
*/
protected function doModifyLimitQuery($query, $limit, $offset)
{
if (null === $limit && null !== $offset) {
return $query . ' LIMIT -1 OFFSET ' . $offset;
}

return parent::doModifyLimitQuery($query, $limit, $offset);
}

/**
* {@inheritDoc}
*/
Expand Down
6 changes: 6 additions & 0 deletions tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,12 @@ public function testModifyLimitQueryWithEmptyOffset()
$this->assertEquals('SELECT * FROM user LIMIT 10', $sql);
}

public function testModifyLimitQueryWithOffsetAndEmptyLimit()
{
$sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', null, 10);
$this->assertEquals('SELECT * FROM user LIMIT -1 OFFSET 10', $sql);
}

public function getGenerateAlterTableSql()
{
return array(
Expand Down

0 comments on commit 2a9dd3c

Please sign in to comment.