Ticket #1601 (closed defect: fixed)
[PATCH] Workaround in paginate for databases without offset
| Reported by: | joelpearson | Owned by: | 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
Change History
Changed 4 years ago by joelpearson
-
attachment
simulate_offset.diff
added
Changed 4 years ago 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
Workaround is off by default, must be enabled in config file