Android SQLiteException "no error" at cursor

I am using the Trigger.io plugin to manage my own database on Android and recently started getting this exception:

android.database.sqlite.SQLiteException: not an error
at android.database.sqlite.SQLiteQuery.nativeFillWindow(Native Method)
at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:86)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:164)
at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:156)
at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:161)
at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:201)
at io.trigger.forge.android.modules.database.NotesDatabase.cursorToArray(NotesDatabase.java:176)
at io.trigger.forge.android.modules.database.NotesDatabase.queryToObjects(NotesDatabase.java:127)
at io.trigger.forge.android.modules.database.NotesDatabase.queryToObjects(NotesDatabase.java:120)
at io.trigger.forge.android.modules.database.API.query(API.java:50)

      

So the functions mentioned in the stacktrace are as follows:

//"atomic" is always true when this is called
public synchronized JSONArray queryToObjects(String query, boolean atomic) throws JSONException{
    if(atomic) open();
    Cursor c = db.rawQuery(query, null);
    JSONArray notes = cursorToArray(c);
    c.close();
    if(atomic) close();
    return notes;
}

private JSONArray cursorToArray(Cursor c) throws JSONException{
    final String[] columnNames = c.getColumnNames();
    JSONArray results = new JSONArray();

    for (c.moveToFirst();!c.isAfterLast();c.moveToNext()){
        JSONObject object = new JSONObject();
        for(String name : columnNames){
            int index = c.getColumnIndex(name);
                            //"get" is defined elsewhere, but this line never executes
            object.put(name, get(c, index));
        }
        results.put(object);
    }
    return results;
}

      

and I am using the following query:

select different hashtags as name, count (hashtags) as score from NoteTag group using hashtags

Has anyone experienced something like this before? Thanks in advance for any suggestions you can make!

Update: There seems to be something fundamentally wrong with the cursor: the call to "getColumnNames" returns an empty array, and the call to c.getCount () throws the same error.

Another update:

Some queries that work:

select * from Notes where  localID in (select distinct localID from NoteTag where hashtags == '#gold') and  status != 'delete'  order by timestamp desc  limit 0,25

select * from Notes where  localID in (select distinct localID from NoteTag where hashtags == '#woot' intersect select distinct localID from NoteTag where hashtags == '#yeah') and  status != 'delete'  order by timestamp desc  limit 0,25

      

+3


source to share


1 answer


Solution: The source of the problem was the way I was calling the forge function on the javascript side. I was passing in an object where a string was expected (a "request" parameter) that was forced into a string using its own bridge. This exception was SQLite's very roundabout way of saying "this is not a query."



+4


source







All Articles