我尝试通过sqflite运行查询并得到以下错误:
DatabaseException(no such column: true (code 1): , while compiling: select (case true WHEN true THEN 111 END) xkey1 from tb_path
以下是SQL步骤:
create table tb_path(name text, age text);
db.rawQuery('select (case true WHEN true THEN 111 END) xkey1 from tb_path');
和上面的错误出现了。如果我尝试通过Sqlite Expert Personal(Windows版SQLITE工具)运行SQL,这样可以正常工作。
当我在sqlite命令行(Ubuntu 18.04)中尝试您的步骤时:
$ select sqlite_version();
3.22.0
$ CREATE TABLE tb_path(from_ text, to_ text);
$ select (case true WHEN true THEN 111 END) xkey1 from tb_path;
Error: no such column: true
如果我尝试使用最新的二进制下载(3.27),我不会收到错误:
$ select sqlite_version();
3.27.2
$ CREATE TABLE tb_path(from_ text, to_ text);
$ select (case true WHEN true THEN 111 END) xkey1 from tb_path;
所以也许这样的声明只适用于较新的sqlite版本,因为sqflite使用iOS / Android平台提供的任何东西,它可能还不支持(请参阅Android上的运输sqlite版本的良好列表:Version of SQLite used in Android?)