posted 18 years ago
Hi,
I had a probem with JForum 2.1.4 in which it was impossible to view posts pending approval from a moderator because of the way the postgres dao was implemented. Postgres requires a "LIMIT X OFFSET Y" clause at the end of a query to get at most X rows starting at row number Y. This corresponds to the LIMIT clause in MySql, except that there, there is no OFFSET keyword, but something like it is inferred by a comma-seperated tuple, i.e., "LIMIT Y, X" is the equivilent (note the parameters meaning are in a different order). It follows that the postgres dao classes need to override methods which query for a subset, and flip the order of the start and count parameters (in addition to providing their own versions of the SELECT sql). Inexplicably, in 2.1.4, the postgres implementation of ModerationModel did this:
instead of this:
In 2.1.6, ModerationModel no longer constrains the query to a range, so this oddity is gone, however, in checking all the LIMIT OFFSET queries in 2.1.6, I found all were handled correctly except one in PostgresqlUserDAO, where this:
appears instead of this:
start > 0 ? start + count : 0 will work correctly if start == 0, but if it is anything else, the wrong range will be returned. For example, if start = 10 and count = 10, it will return rows 20 through 29 (if they exist), rather than rows 10 through 19.
Unless I totally misunderstand postgres sql, this is a bug.
Dave
[originally posted on jforum.net by Anonymous]