Skip to content

Commit

Permalink
修复sqliteBUG
Browse files Browse the repository at this point in the history
  • Loading branch information
xiyoo0812 committed Apr 19, 2024
1 parent 76cbdc4 commit dc20a6e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions script/driver/sqlite.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit dc20a6e

Please sign in to comment.