From dc20a6ec38ef7698681526ec073b689755d0d189 Mon Sep 17 00:00:00 2001 From: xiyoo0812 Date: Fri, 19 Apr 2024 11:23:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DsqliteBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/driver/sqlite.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/script/driver/sqlite.lua b/script/driver/sqlite.lua index e4456b58..a7437d57 100644 --- a/script/driver/sqlite.lua +++ b/script/driver/sqlite.lua @@ -67,8 +67,8 @@ end function Sqlite:init_sheet(sheet, primary_id) log_debug("[Sqlite][init_sheet] sheet:{} primary_id:{}", sheet, primary_id) - self.driver.exec(sformat("CREATE TABLE IF NOT EXISTS '%s' (KEY %s PRIMARY KEY NOT NULL, VALUE BLOB);", sheet, - type(primary_id) == "string" and "TEXT" or "INTEGER")) + local sql = "CREATE TABLE IF NOT EXISTS '%s' (KEY %s PRIMARY KEY NOT NULL, VALUE BLOB);" + self.driver.exec(sformat(sql, sheet, type(primary_id) == "string" and "TEXT" or "INTEGER")) self:register_prepare(sheet) end @@ -101,8 +101,8 @@ function Sqlite:drop(dbname) end function Sqlite:autoinc_id() - local sql = sformat("INSERT INTO '%s' (VALUE) VALUES(%s); SELECT last_insert_rowid() AS AUTOINC_ID;", AUTOINCKEY, quanta.now) - local code, record = self.driver.find(sql) + local sql = "INSERT INTO '%s' (VALUE) VALUES(%s); SELECT last_insert_rowid() AS AUTOINC_ID;" + local code, record = self.driver.find(sformat(sql, AUTOINCKEY, quanta.now)) if code ~= SQLITE_OK or not next(record) then log_err("[Sqlite][autoinc_id] update fail code:{} record:{}", code, record) return false