This implementation of LimitHandler is unable to handle one query with "order by" if there is a line break just before "order by" clause. In the method getProcessedSql(), line shallowIndexOfWord( sb, ORDER_BY, 0 ), but if fails if it faces a query like the one below: {code:sql}SELECT * FROM (select NAME, PASSPORT FROM PERSON) X ORDER BY X.NAME, X.PASSPORT;{code}
*Please, keep the line break after "X" above* For this query, consider the following table: {code:sql}CREATE TABLE PERSON ( ID INT PRIMARY KEY, NAME VARCHAR(255) NOT NULL, PASSPORT VARCHAR(255) NOT NULL ); {code} The problem is faced only if there's a RowSelection instance with firstRow > 0 as well as defined values for maxRows and fetchSize, e. g., pagination asking for page 2 or next. It throws one SQLServerException.
One possible fix for this bug would be to replace first line (line 111) of {{SQLServer2005LimitHandler#getProcessedSQL()}} by: {code:java}final StringBuilder sb = new StringBuilder( sql.replaceAll( "\\r|\\n", " " ) );{code}, forcing the query to fit the format *space* + *keyword * + *space* and avoid line breaks. |
|