qicosmos / ormpp

modern C++ ORM, C++17, support mysql, postgresql,sqlite
Apache License 2.0
1.2k stars 260 forks source link

sqlite创建表失败 #151

Open baiyfcu opened 4 months ago

baiyfcu commented 4 months ago

struct GbsUser { using Ptr = std::shared_ptr; 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外套上双引号

Jacyking commented 4 months ago

这个是由于index是关键字~