DDC-43: offset and limit are in the wrong order (at least SQLite) #4929

Closed
doctrinebot opened this Issue Oct 12, 2009 · 1 comment

2 participants

@doctrinebot

Jira issue originally created by user itoijala:

The following code creates an error:

Code:

$query = Itoijala_Singletons::getDoctrine()->createQueryBuilder();
$query->select('e')->from('Model\Guestbook\Entry e');
$query->andWhere('e.dateDeleted IS NULL')->andWhere('e.unlocked = TRUE');
$query->orderBy('e.dateCreated', 'DESC')->setFirstResult(($this->_getParam('page') - 1) * 15);
$query->setMaxResults(15);

$this->view->entries = $query->getQuery()->getResult();

Error:
SQLSTATE[HY000]: General error: 1 near "OFFSET": syntax error

The DQL:
SELECT e FROM Model\Guestbook\Entry e WHERE (e.dateDeleted IS NULL) AND (e.unlocked = TRUE) ORDER BY e.dateCreated DESC

The SQL:
SELECT g0.id AS id0, g0_.name AS name1, g0_.email AS email2, g0_.homepage AS homepage3, g0_.content AS content4, g0_.comment AS comment5, g0_.unlocked AS unlocked6, g0_.date_created AS date_created7, g0_.date_updated AS date_updated8, g0_.date_deleted AS date_deleted9, g0_.creator_id AS creator_id10, g0_.updater_id AS updater_id11, g0_.deleter_id AS deleter_id12 FROM guestbook_entries g0_ WHERE (g0_.date_deleted IS NULL) AND (g0_.unlocked = 1) ORDER BY g0_.datecreated DESC OFFSET 0 LIMIT 15

SQLite expects offset to come after limit. writeLimitClause in AbstractPlatform works correctly and is not overriden by SqlitePlatform. This means that the bug is somewhere else. writeLimitClause is not called.

@doctrinebot

Issue was closed with resolution "Fixed"

@jwage jwage was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.0-ALPHA3 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment