j256 / ormlite-android

ORMLite Android functionality used in conjunction with ormlite-core
http://ormlite.com/
ISC License
1.59k stars 367 forks source link

AndroidCompiledStatement appends duplicate LIMIT #71

Open andrew-bowley opened 8 years ago

andrew-bowley commented 8 years ago

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.

SSvistunov commented 7 years ago

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

j256 commented 7 years ago

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