Ticket #1601 (closed defect: fixed)

Opened 7 months ago

Last modified 7 months ago

[PATCH] Workaround in paginate for databases without offset

Reported by: joelpearson Assigned to: anonymous
Priority: normal Milestone: 1.0.4
Component: TurboGears Version: 1.0.4b2
Severity: normal Keywords: paginate
Cc:

Description

Using the paginate decorator in 1.0.4b2 with certain databases in SQLAlchemy produces the following exception:

InvalidRequestError: [database name] does not support LIMIT with an offset

I've attached a patch that works around this problem. This workaround is off by default, and must be enabled by adding a new variable to the [global] section of the dev.cfg and/or prod.cfg file:

paginate.simulate_offset=True

If this variable exists in the config file and evaluates to True, then paginate uses "limit" in the database, but simulates "offset" by skipping over the results until it reaches the requested records. This is not particularly efficient, but in most cases it's more useful than the traceback screen that would otherwise result.

Discussion at http://groups.google.com/group/turbogears/t/10b51e9d8562fe63?hl=en

Attachments

simulate_offset.diff (0.9 kB) - added by joelpearson on 11/01/07 14:09:44.
Workaround is off by default, must be enabled in config file
simulate_offset_auto.diff (2.2 kB) - added by joelpearson on 11/01/07 14:14:04.
Workaround is on by default for certain databases, but can be forced on or off in config file

Change History

11/01/07 14:09:44 changed by joelpearson

  • attachment simulate_offset.diff added.

Workaround is off by default, must be enabled in config file

11/01/07 14:14:04 changed by joelpearson

  • attachment simulate_offset_auto.diff added.

Workaround is on by default for certain databases, but can be forced on or off in config file

11/03/07 05:55:38 changed by paj

  • status changed from new to closed.
  • resolution set to fixed.

Thanks for this Joel, your patch looks good. Commited in [3592] and [3593].