Verified
Status Update
Comments
yb...@google.com <yb...@google.com> #2
Thanks for the thorough report - you're right about the problem, and the workaround looks good - it even handles the fast cases for initialization and setList(null) nicely.
Fix and tests submitted internally, should go out with next paging release.
Fix and tests submitted internally, should go out with next paging release.
Description
Version used: 1.0.0-alpha1
Devices/Android versions reproduced on: Google Pixel
If @Quary has three or more IN query parameters then DAO code generation has an error.
For example. Below query has three in query parameters ids, price and type.
@query("select * from products where name like :query and id in (:ids) and price in (:price) and type in (:type)")
LiveData<List> searchProducts(String query,int[] ids,int[] price,int[] type);
Error
Error:(258, 31) error: ';' expected
Error:(258, 36) error: not a statement
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
Code Generated
Error in _argIndex = 2 + _inputSize, + _inputSize_1;
@override
public LiveData<List> searchProducts(String query, int[] ids, int[] price,
int[] type) {
StringBuilder _stringBuilder = StringUtil.newStringBuilder();
_stringBuilder.append("select * from products where name like ");
_stringBuilder.append("?");
_stringBuilder.append(" and id in (");
final int _inputSize = ids.length;
StringUtil.appendPlaceholders(_stringBuilder, _inputSize);
_stringBuilder.append(") and price in (");
final int _inputSize_1 = price.length;
StringUtil.appendPlaceholders(_stringBuilder, _inputSize_1);
_stringBuilder.append(") and type in (");
final int _inputSize_2 = type.length;
StringUtil.appendPlaceholders(_stringBuilder, _inputSize_2);
_stringBuilder.append(")");
final String _sql = _stringBuilder.toString();
final int _argCount = 1 + _inputSize + _inputSize_1 + _inputSize_2;
final RoomSQLiteQuery _statement = RoomSQLiteQuery.acquire(_sql, _argCount);
int _argIndex = 1;
if (query == null) {
_statement.bindNull(_argIndex);
} else {
_statement.bindString(_argIndex, query);
}
_argIndex = 2;
for (int _item : ids) {
_statement.bindLong(_argIndex, _item);
_argIndex ++;
}
_argIndex = 2 + _inputSize;
for (int _item_1 : price) {
_statement.bindLong(_argIndex, _item_1);
_argIndex ++;
}