SQLite 查询生成器:"appendwhere" 不添加 "and"

SQLLite QueryBuilder: "appendwhere" doesn't add "and"

我认为 "appendwhere" 应该处理从句到正确 sql 代码的转换。这就是我写以下内容的原因:

                  if (match % 2 == 0) qBuilder.appendWhere("_id=" + uri.getLastPathSegment() + " ");

            if (hasRecordExistField) qBuilder.appendWhere(TableObject.FIELD_RECORD_EXISTS + "=" + Globals.DEFAULT_EXISTS + " ");
            c = qBuilder.query(
                    db,
                    projection,
                    selection,
                    selectionArgs,
                    null,
                    null,
                    null);

然而,当我执行时,两个 "appendwhere" 子句只是简单地连接在一起。如果 "appendwhere" 不注意在子句之间添加“ AND ”,它有什么用?

错误描述如下:

near "record_exists": syntax error (code 1): , while compiling: SELECT name FROM game WHERE (_id=0 record_exists=1 )

Yet, when I execute, both "appendwhere" clauses are simply concatenated.

这就是文档所说的:

The final WHERE clause looks like: WHERE (<append chunk 1><append chunk2>) AND (<query() selection parameter>)

在你的情况下,你的两件作品分别是 <append chunk 1><append chunk 2>ANDbuildQuery() 调用的 selection 参数一起出现。