gpt4 book ai didi

游标中的 Android SQLiteException "not an error"

转载 作者:太空宇宙 更新时间:2023-11-03 13:29:39 25 4
gpt4 key购买 nike

我正在使用编写 Trigger.io 插件来管理 Android 上的 native 数据库,并且最近开始遇到此异常:

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(hashtags) 作为根据主题标签从 NoteTag 组中计数

有没有人遇到过这样的事情?提前感谢您提出的任何建议!

更新:Cursor 似乎存在根本性的错误:调用“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 端调用 forge 函数的方式。我正在传递一个需要字符串的对象(“查询”参数),它被 native 桥强制转换为字符串。这个异常是 SQLite 非常迂回的表达“这不是查询”的方式。

关于游标中的 Android SQLiteException "not an error",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14944238/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com