ormpp icon indicating copy to clipboard operation
ormpp copied to clipboard

sqlite创建表失败

Open baiyfcu opened this issue 11 months ago • 1 comments

struct GbsUser { using Ptr = std::shared_ptr<GbsUser>; int32_t index = 0; std::string id; std::string username; std::string password; std::string role; bool enable = false; std::string creator; long long update_ts = 0;

bool operator==(const GbsUser &info) {
    if (info.id != id || info.username != username || info.password != password || info.role != role
        || info.enable != enable || info.creator != creator) {
        return false;
    } else
        return true;
}

}; REGISTER_AUTO_KEY(GbsUser, index) REFLECTION_WITH_NAME(GbsUser, "user", index, id, username, password, role, enable, creator, update_ts)

generate_createtb_sql生成如下: CREATE TABLE IF NOT EXISTS user(index INTEGER PRIMARY KEY AUTOINCREMENT , id TEXT , username TEXT , password TEXT , role TEXT , enable INTEGER , creator TEXT , update_ts INTEGER ) 执行sql时失败,经测试需要改为如下才可以: CREATE TABLE IF NOT EXISTS user(" index " INTEGER PRIMARY KEY AUTOINCREMENT , id TEXT , username TEXT , password TEXT , role TEXT , enable INTEGER , creator TEXT , update_ts INTEGER ) 在index外套上双引号

baiyfcu avatar Mar 02 '24 09:03 baiyfcu

这个是由于index是关键字~

Jacyking avatar Mar 05 '24 01:03 Jacyking