游标中的Android SQLiteException“不是错误”
作者:互联网
我正在使用编写Trigger.io插件来管理Android上的本机数据库,并且最近开始出现此异常:
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)
因此,堆栈跟踪中提到的功能是:
//"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;
}
我正在使用的查询是:
选择不同的主题标签作为名称,将count(主题标签)作为NoteTag组中按主题计数的计数
有没有人经历过这样的事情?预先感谢您可以提出的任何建议!
更新:
游标似乎根本上有问题:对“ getColumnNames”的调用返回一个空数组,并且调用c.getCount()会产生相同的错误.
另一个更新:
一些有效的查询:
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
解决方法:
解决方案:问题的根源是我在javascript端调用伪函数的方式.我正在传递一个对象,该对象需要一个字符串(“查询”参数),该字符串由本机桥强制转换为字符串.这种例外是SQLite所说的“这不是查询”的一种非常round回的方式.
标签:sqlite,trigger-io,android 来源: https://codeday.me/bug/20191031/1974288.html