ormlite-android icon indicating copy to clipboard operation
ormlite-android copied to clipboard

AndroidCompiledStatement appends duplicate LIMIT

Open andrew-bowley opened this issue 9 years ago • 2 comments

The error is in com.j256.ormlite.android.AndroidCompiledStatement method getCursor(). An example error report:

Problems executing Android query: SELECT * FROM categories WHERE node_id = ? LIMIT 1 LIMIT 1

The error occurs when setMaxRows() has set the max field to non-null. A subsequent getCursor() call appends a LIMIT statement regardless of whether one is already appended to the original statement passed in the constructor.

One simple fix would be to ignore the max field when a limit is already appended to the statement.

andrew-bowley avatar Aug 05 '16 08:08 andrew-bowley

Confirm this bug in version 5.0, need to check previous limit statement before adding new in sql string.

SSvistunov avatar Feb 02 '17 10:02 SSvistunov

Can someone generate a unit test for me to show how the code fails?

j256 avatar Feb 04 '17 19:02 j256