Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1601 (closed defect: fixed)

Opened 9 years ago

Last modified 9 years ago

[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

simulate_offset.diff Download (935 bytes) - added by joelpearson 9 years ago.
Workaround is off by default, must be enabled in config file
simulate_offset_auto.diff Download (2.2 KB) - added by joelpearson 9 years ago.
Workaround is on by default for certain databases, but can be forced on or off in config file

Change History

Changed 9 years ago by joelpearson

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

Changed 9 years ago by joelpearson

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

comment:1 Changed 9 years ago 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].

Note: See TracTickets for help on using tickets.