In my Android Studio project I have implemented a database (managed by Room). In my Dao file, I have the following query which causes an error:
SELECT tab1.list_id, ... FROM
(SELECT list_id, ... FROM list_table) AS tab1
LEFT JOIN
(SELECT list_id, ... FROM list_table NATURAL JOIN product_table NATURAL JOIN list_product_table GROUP BY list_id) AS tab2
ON tab1.list_id = tab2.list_id
ORDER BY list_position ASC, tab1.list_id ASC;
The error says java.lang.IllegalArgumentException: column '`list_id`' does not exist
. The error points to the file, which was automatically created by Room.
...
return __db.getInvalidationTracker().createLiveData(new String[]{"list_table","product_table","list_product_table"}, false, new Callable<List<ShoppingListDisplayValues>>() {
@Override
public List<ShoppingListDisplayValues> call() throws Exception {
final Cursor _cursor = DBUtil.query(__db, _statement, false, null);
try {
final int _cursorIndexOfPosition = CursorUtil.getColumnIndexOrThrow(_cursor, "list_position");
final int _cursorIndexOfId = CursorUtil.getColumnIndexOrThrow(_cursor, "list_id");
...
To be more specific, the error points to the line:
final int _cursorIndexOfId = CursorUtil.getColumnIndexOrThrow(_cursor, "list_id");
Now my question is, could this error result from the left join? The really weird thing is, that the code works on some devices and on other not. Would be really glad, if someone has an idea.